Skip to content

Commit

Permalink
format and delete failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ate47 committed Dec 19, 2024
1 parent c3b3c4a commit 3e66d36
Show file tree
Hide file tree
Showing 12 changed files with 124 additions and 155 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ public static void encode(OutputStream out, long value) throws IOException {
}

/**
* Encode a str vbyte, this vbyte is using the 0x80 bit in between instead of the end to avoid a 0 byte inside
* the data
* @param out string
* Encode a str vbyte, this vbyte is using the 0x80 bit in between instead
* of the end to avoid a 0 byte inside the data
*
* @param out string
* @param value value to encode
*/
public static void encodeStr(ReplazableString out, long value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,17 +277,13 @@ default TripleID toTripleId(TripleString tsstr) {

default TripleString toTripleString(TripleID tid) {
if (tid.isQuad()) {
return new QuadString(
idToString(tid.getSubject(), TripleComponentRole.SUBJECT),
return new QuadString(idToString(tid.getSubject(), TripleComponentRole.SUBJECT),
idToString(tid.getPredicate(), TripleComponentRole.PREDICATE),
idToString(tid.getObject(), TripleComponentRole.OBJECT),
idToString(tid.getGraph(), TripleComponentRole.GRAPH)
);
idToString(tid.getGraph(), TripleComponentRole.GRAPH));
}
return new TripleString(
idToString(tid.getSubject(), TripleComponentRole.SUBJECT),
return new TripleString(idToString(tid.getSubject(), TripleComponentRole.SUBJECT),
idToString(tid.getPredicate(), TripleComponentRole.PREDICATE),
idToString(tid.getObject(), TripleComponentRole.OBJECT)
);
idToString(tid.getObject(), TripleComponentRole.OBJECT));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ public static DictionaryPrivate createDictionary(HDTOptions spec) {
case HDTOptionsKeys.DICTIONARY_TYPE_VALUE_MULTI_OBJECTS_LANG -> new MultipleSectionDictionaryLang(spec);
case HDTOptionsKeys.DICTIONARY_TYPE_VALUE_MULTI_OBJECTS_LANG_QUAD ->
new MultipleSectionDictionaryLang(spec, true);
case HDTOptionsKeys.DICTIONARY_TYPE_VALUE_MULTI_OBJECTS_LANG_PREFIXES -> new MultipleSectionDictionaryLangPrefixes(spec);
case HDTOptionsKeys.DICTIONARY_TYPE_VALUE_MULTI_OBJECTS_LANG_PREFIXES ->
new MultipleSectionDictionaryLangPrefixes(spec);
default -> throw new IllegalFormatException("Implementation of dictionary not found for " + name);
};
}
Expand Down Expand Up @@ -281,27 +282,28 @@ public static DictionaryKCat createDictionaryKCat(Dictionary dictionary) {
case HDTVocabulary.DICTIONARY_TYPE_FOUR_SECTION, HDTVocabulary.DICTIONARY_TYPE_FOUR_QUAD_SECTION ->
new FourSectionDictionaryKCat(dictionary);
case HDTVocabulary.DICTIONARY_TYPE_MULT_SECTION -> new MultipleSectionDictionaryKCat(dictionary);
case HDTVocabulary.DICTIONARY_TYPE_MULT_SECTION_LANG, HDTVocabulary.DICTIONARY_TYPE_MULT_SECTION_LANG_QUAD ->
case HDTVocabulary.DICTIONARY_TYPE_MULT_SECTION_LANG, HDTVocabulary.DICTIONARY_TYPE_MULT_SECTION_LANG_QUAD ->
new MultipleSectionLangDictionaryKCat(dictionary);
case HDTVocabulary.DICTIONARY_TYPE_MULT_SECTION_LANG_PREFIXES -> new MultipleSectionLangPrefixesDictionaryKCat(dictionary);
case HDTVocabulary.DICTIONARY_TYPE_MULT_SECTION_LANG_PREFIXES ->
new MultipleSectionLangPrefixesDictionaryKCat(dictionary);
default -> throw new IllegalArgumentException("Implementation of DictionaryKCat not found for " + type);
};
}

public static DictionaryPrivate createWriteDictionary(String type, HDTOptions spec,
DictionarySectionPrivate subject, DictionarySectionPrivate predicate, DictionarySectionPrivate object,
DictionarySectionPrivate shared, TreeMap<ByteString, DictionarySectionPrivate> sub,
DictionarySectionPrivate graph, PrefixesStorage prefixesStorage) {
DictionarySectionPrivate subject, DictionarySectionPrivate predicate, DictionarySectionPrivate object,
DictionarySectionPrivate shared, TreeMap<ByteString, DictionarySectionPrivate> sub,
DictionarySectionPrivate graph, PrefixesStorage prefixesStorage) {
if (graph == null) {
return switch (type) {
case HDTVocabulary.DICTIONARY_TYPE_FOUR_SECTION, HDTVocabulary.DICTIONARY_TYPE_FOUR_PSFC_SECTION ->
new WriteFourSectionDictionary(spec, subject, predicate, object, shared);
case HDTVocabulary.DICTIONARY_TYPE_MULT_SECTION ->
new WriteMultipleSectionDictionary(spec, subject, predicate, shared, sub);
case HDTVocabulary.DICTIONARY_TYPE_MULT_SECTION_LANG ->
new WriteMultipleSectionDictionaryLang(spec, subject, predicate, shared, sub);
case HDTVocabulary.DICTIONARY_TYPE_MULT_SECTION_LANG_PREFIXES ->
new WriteMultipleSectionDictionaryLangPrefixes(spec, subject, predicate, shared, sub, prefixesStorage);
case HDTVocabulary.DICTIONARY_TYPE_MULT_SECTION_LANG ->
new WriteMultipleSectionDictionaryLang(spec, subject, predicate, shared, sub);
case HDTVocabulary.DICTIONARY_TYPE_MULT_SECTION_LANG_PREFIXES ->
new WriteMultipleSectionDictionaryLangPrefixes(spec, subject, predicate, shared, sub, prefixesStorage);
default -> throw new IllegalArgumentException("Unknown dictionary type " + type);
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public static DictionaryType fromDictionaryType(String dictType) {
case HDTOptionsKeys.DICTIONARY_TYPE_VALUE_MULTI_OBJECTS, HDTVocabulary.DICTIONARY_TYPE_MULT_SECTION -> MSD;
case HDTVocabulary.DICTIONARY_TYPE_MULT_SECTION_LANG, HDTOptionsKeys.DICTIONARY_TYPE_VALUE_MULTI_OBJECTS_LANG,
HDTVocabulary.DICTIONARY_TYPE_MULT_SECTION_LANG_QUAD,
HDTOptionsKeys.DICTIONARY_TYPE_VALUE_MULTI_OBJECTS_LANG_QUAD, HDTOptionsKeys.DICTIONARY_TYPE_VALUE_MULTI_OBJECTS_LANG_PREFIXES,
HDTOptionsKeys.DICTIONARY_TYPE_VALUE_MULTI_OBJECTS_LANG_QUAD,
HDTOptionsKeys.DICTIONARY_TYPE_VALUE_MULTI_OBJECTS_LANG_PREFIXES,
HDTVocabulary.DICTIONARY_TYPE_MULT_SECTION_LANG_PREFIXES ->
MSDL;
default -> throw new NotImplementedException("Can't find type for name: " + dictType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ public WriteMultipleSectionDictionaryLangPrefixes(HDTOptions spec, Path filename
prefixesStorage = new PrefixesStorage();
prefixesStorage.loadConfig(spec.get(HDTOptionsKeys.LOADER_PREFIXES));
}

public WriteMultipleSectionDictionaryLangPrefixes(HDTOptions spec, DictionarySectionPrivate subjects,
DictionarySectionPrivate predicates, DictionarySectionPrivate shared,
TreeMap<ByteString, DictionarySectionPrivate> objects, PrefixesStorage prefixesStorage) {
DictionarySectionPrivate predicates, DictionarySectionPrivate shared,
TreeMap<ByteString, DictionarySectionPrivate> objects, PrefixesStorage prefixesStorage) {
this(spec, subjects, predicates, shared, objects, null, prefixesStorage);
}

Expand All @@ -86,7 +87,8 @@ public WriteMultipleSectionDictionaryLangPrefixes(HDTOptions spec, DictionarySec

public WriteMultipleSectionDictionaryLangPrefixes(HDTOptions spec, DictionarySectionPrivate subjects,
DictionarySectionPrivate predicates, DictionarySectionPrivate shared,
TreeMap<ByteString, DictionarySectionPrivate> objects, DictionarySectionPrivate graph, PrefixesStorage prefixesStorage) {
TreeMap<ByteString, DictionarySectionPrivate> objects, DictionarySectionPrivate graph,
PrefixesStorage prefixesStorage) {
super(spec);
// useless
this.filename = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ private KCatImpl(List<?> hdtFileNames, List<? extends Bitmap> deleteBitmaps, HDT
// we can disable the prefix mapping
for (HDT hdt : hdts) {
hdt.getDictionary().setPrefixMapping(false);
assert !(hdt.getDictionary() instanceof MultipleSectionDictionaryLangPrefixes dpr) || dpr.getPrefixesStorage(false) != null;
assert !(hdt.getDictionary() instanceof MultipleSectionDictionaryLangPrefixes dpr)
|| dpr.getPrefixesStorage(false) != null;
}
prefixesStorage = storage.copy();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public class KCatMerger implements AutoCloseable {
* Create KCatMerger
*
* @param hdts the hdts to cat
* @param deletedTriple deleted triples
* @param deletedTriple deleted triples
* @param location working location
* @param listener listener to log the state
* @param bufferSize buffer size
Expand All @@ -105,25 +105,27 @@ public class KCatMerger implements AutoCloseable {
* @throws java.io.IOException io exception
*/
public KCatMerger(HDT[] hdts, BitmapTriple[] deletedTriple, CloseSuppressPath location, ProgressListener listener,
int bufferSize, String dictionaryType, boolean quad, HDTOptions spec) throws IOException {
int bufferSize, String dictionaryType, boolean quad, HDTOptions spec) throws IOException {
this(hdts, deletedTriple, location, listener, bufferSize, dictionaryType, quad, spec, null);
}

/**
* Create KCatMerger
*
* @param hdts the hdts to cat
* @param deletedTriple deleted triples
* @param location working location
* @param listener listener to log the state
* @param bufferSize buffer size
* @param dictionaryType dictionary type
* @param quad quad
* @param spec spec to config the HDT
* @param hdts the hdts to cat
* @param deletedTriple deleted triples
* @param location working location
* @param listener listener to log the state
* @param bufferSize buffer size
* @param dictionaryType dictionary type
* @param quad quad
* @param spec spec to config the HDT
* @param prefixesStorage prefixes
* @throws java.io.IOException io exception
*/
public KCatMerger(HDT[] hdts, BitmapTriple[] deletedTriple, CloseSuppressPath location, ProgressListener listener,
int bufferSize, String dictionaryType, boolean quad, HDTOptions spec, PrefixesStorage prefixesStorage) throws IOException {
int bufferSize, String dictionaryType, boolean quad, HDTOptions spec, PrefixesStorage prefixesStorage)
throws IOException {
this.hdts = hdts;
this.listener = listener;
this.dictionaryType = dictionaryType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,7 @@ public static CharSequence cutPrefToRes(CharSequence str, PrefixesStorage prefix

int pid = val.getValue().intValue() - 1;
ByteString prefixStr = prefixes.getPrefix(pid);
ReplazableString prefixedValue = new ReplazableString(
str.length() - off + prefixStr.length());
ReplazableString prefixedValue = new ReplazableString(str.length() - off + prefixStr.length());
prefixedValue.appendNoCompact(prefixStr);
prefixedValue.appendNoCompact(str, off, str.length() - off);
return prefixedValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ public void loadConfig(String cfg) {
}

/**
* add a prefix to the storage, the storage should be committed after using {@link #commitPrefixes()} to keep integrity
* add a prefix to the storage, the storage should be committed after using
* {@link #commitPrefixes()} to keep integrity
*
* @param prefix prefix
*/
public void addPrefix(CharSequence prefix) {
Expand Down
Loading

0 comments on commit 3e66d36

Please sign in to comment.