Skip to content

Commit

Permalink
Merge pull request #441 from the-qa-company/GH-440-multi-index-updates
Browse files Browse the repository at this point in the history
GH-440 Add delete bitmap to multiple co-indexes
  • Loading branch information
ate47 authored Jan 11, 2024
2 parents 3ec8dc4 + e60867b commit 363f788
Show file tree
Hide file tree
Showing 19 changed files with 542 additions and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,11 @@ public long getLastTriplePosition() {
public TripleComponentOrder getOrder() {
return TripleComponentOrder.getAcceptableOrder(searchOrderMask);
}

@Override
public boolean isLastTriplePositionBoundToOrder() {
return false;
}
};
}

Expand Down Expand Up @@ -411,6 +416,11 @@ public long getLastTriplePosition() {
public TripleComponentOrder getOrder() {
return TripleComponentOrder.getAcceptableOrder(searchOrderMask);
}

@Override
public boolean isLastTriplePositionBoundToOrder() {
return false;
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,9 @@ public long getLastTriplePosition() {
public TripleComponentOrder getOrder() {
return TripleComponentOrder.Unknown;
}

@Override
public boolean isLastTriplePositionBoundToOrder() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,9 @@ public TripleComponentOrder getOrder() {
return iterator.getOrder();
}

@Override
public boolean isLastTriplePositionBoundToOrder() {
return iterator.isLastTriplePositionBoundToOrder();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ public TripleComponentOrder getOrder() {
return iterator.getOrder();
}

@Override
public boolean isLastTriplePositionBoundToOrder() {
return iterator.isLastTriplePositionBoundToOrder();
}

public static void setBlockSize(int size) {
DEFAULT_BLOCK_SIZE = size;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
import java.io.Writer;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
Expand All @@ -41,6 +43,7 @@
import java.util.function.IntSupplier;
import java.util.function.LongSupplier;
import java.util.function.Supplier;
import java.util.stream.Collectors;

/**
* Options storage, see {@link HDTOptionsKeys} for more information.
Expand Down Expand Up @@ -488,6 +491,8 @@ default void set(String key, Object value) {
set(key, fs);
} else if (value instanceof Path p) {
set(key, p.toAbsolutePath().toString());
} else if (value instanceof EnumSet<?> p) {
set(key, p);
} else if (value instanceof File f) {
set(key, f.getAbsolutePath());
} else {
Expand Down Expand Up @@ -724,4 +729,73 @@ public Set<?> getKeys() {
}
};
}

/**
* set enum set, the elements are split using comas
*
* @param key key
* @param set set
*/
default void set(String key, EnumSet<?> set) {
set(key, set.stream().map(Enum::name).collect(Collectors.joining(",")));
}

/**
* get enum set from value, the elements are split using comas
*
* @param key key
* @param cls enum class
* @return enum set
* @param <E> enum type
*/
default <E extends Enum<E>> EnumSet<E> getEnumSet(String key, Class<E> cls) {
return getEnumSet(key, cls, EnumSet.noneOf(cls));
}

/**
* get enum set from value, the elements are split using comas
*
* @param key key
* @param cls enum class
* @param defaultValue default value
* @return enum set
* @param <E> enum type
*/
default <E extends Enum<E>> EnumSet<E> getEnumSet(String key, Class<E> cls, EnumSet<E> defaultValue) {
return getEnumSet(key, cls, () -> defaultValue);
}

/**
* get enum set from value, the elements are split using comas
*
* @param key key
* @param cls enum class
* @param defaultValue default value supplier
* @return enum set
* @param <E> enum type
*/
default <E extends Enum<E>> EnumSet<E> getEnumSet(String key, Class<E> cls, Supplier<EnumSet<E>> defaultValue) {
String val = get(key);

if (val == null || val.isEmpty()) {
return defaultValue.get();
}

EnumSet<E> set = EnumSet.noneOf(cls);

String[] values = val.split(",");

mainFor:
for (String value : values) {
for (E e : cls.getEnumConstants()) {
if (e.name().equalsIgnoreCase(value)) {
set.add(e);
continue mainFor;
}
}
throw new IllegalArgumentException("Bad option value: " + value);
}

return set;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,8 @@ public TripleComponentOrder getOrder() {
return TripleComponentOrder.Unknown;
}

@Override
public boolean isLastTriplePositionBoundToOrder() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

package com.the_qa_company.qendpoint.core.triples;

import java.util.Iterator;

import com.the_qa_company.qendpoint.core.enums.ResultEstimationType;
import com.the_qa_company.qendpoint.core.enums.TripleComponentOrder;

import java.util.Iterator;

/**
* Iterator of TripleID
*/
Expand Down Expand Up @@ -95,4 +95,12 @@ public interface IteratorTripleID extends Iterator<TripleID> {
* @see Triples#findTriple(long)
*/
long getLastTriplePosition();

/**
* @return if the {@link #getLastTriplePosition()} function is returning an
* index based on {@link #getOrder()} or the triples order
*/
default boolean isLastTriplePositionBoundToOrder() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,6 @@ public interface IteratorTripleString extends Iterator<TripleString> {
* @return order of the components from the iterator
*/
TripleComponentOrder getOrder();

boolean isLastTriplePositionBoundToOrder();
}
Original file line number Diff line number Diff line change
Expand Up @@ -293,4 +293,9 @@ public void remove() {
public long getLastTriplePosition() {
return lastPosition;
}

@Override
public boolean isLastTriplePositionBoundToOrder() {
return true;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.the_qa_company.qendpoint.store;

import com.the_qa_company.qendpoint.compiler.ParsedStringValue;
import com.the_qa_company.qendpoint.core.enums.TripleComponentOrder;
import com.the_qa_company.qendpoint.core.hdt.HDTVersion;

import java.io.File;
Expand Down Expand Up @@ -226,27 +227,33 @@ public String getHDTNewIndexV11() {
* @return the delete triple
* {@link com.the_qa_company.qendpoint.utils.BitArrayDisk} file
*/
@ParsedStringValue("store.deleteBitmap")
public String getTripleDeleteArr() {
return this.locationHdt + "triples-delete.arr";
public String getTripleDeleteArr(TripleComponentOrder order) {
if (order == TripleComponentOrder.SPO) {
return this.locationHdt + "triples-delete.arr";
}
return this.locationHdt + "triples-delete-" + order.name().toLowerCase() + ".arr";
}

/**
* @return the temp delete triple
* {@link com.the_qa_company.qendpoint.utils.BitArrayDisk} file
*/
@ParsedStringValue("store.tempDeleteBitmap")
public String getTripleDeleteTempArr() {
return this.locationHdt + "triples-delete-temp.arr";
public String getTripleDeleteTempArr(TripleComponentOrder order) {
if (order == TripleComponentOrder.SPO) {
return this.locationHdt + "triples-delete-temp.arr";
}
return this.locationHdt + "triples-delete-" + order.name().toLowerCase() + "-temp.arr";
}

/**
* @return the copy delete triple
* {@link com.the_qa_company.qendpoint.utils.BitArrayDisk} file
*/
@ParsedStringValue("store.tempDeleteBitmapCopy")
public String getTripleDeleteCopyArr() {
return this.locationHdt + "triples-delete-cpy.arr";
public String getTripleDeleteCopyArr(TripleComponentOrder order) {
if (order == TripleComponentOrder.SPO) {
return this.locationHdt + "triples-delete-cpy.arr";
}
return this.locationHdt + "triples-delete-" + order.name().toLowerCase() + "-cpy.arr";
}

/**
Expand Down
Loading

0 comments on commit 363f788

Please sign in to comment.