-
Notifications
You must be signed in to change notification settings - Fork 22
Upgrade SnakeYAML #16
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
base: master
Are you sure you want to change the base?
Changes from all commits
d6820dc
2f4d210
86a7d0a
c5b130d
7ea5f86
07d43f9
bc7ab73
10d6ea2
afee805
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,6 @@ | |
| import plugins.Library.util.SkeletonBTreeSet; | ||
| import plugins.Library.util.exec.SimpleProgress; | ||
| import plugins.Library.util.exec.TaskAbortException; | ||
| import plugins.Library.io.serial.Serialiser.*; | ||
| import plugins.Library.io.serial.LiveArchiver; | ||
| import plugins.Library.io.serial.Serialiser; | ||
| import plugins.Library.io.serial.Translator; | ||
|
|
@@ -20,16 +19,9 @@ | |
|
|
||
| import freenet.keys.FreenetURI; | ||
|
|
||
| import java.util.Collection; | ||
| import java.util.Set; | ||
| import java.util.Map; | ||
| import java.util.SortedMap; | ||
| import java.util.SortedSet; | ||
| import java.util.LinkedHashMap; | ||
| import java.util.HashMap; | ||
| import java.util.TreeSet; | ||
| import java.util.TreeMap; | ||
| import java.util.Date; | ||
| import java.text.ParseException; | ||
| import java.text.SimpleDateFormat; | ||
| import java.util.*; | ||
| import java.io.File; | ||
|
|
||
| /** | ||
|
|
@@ -187,27 +179,52 @@ public IndexTranslator(LiveArchiver<Map<String, Object>, SimpleProgress> subsrl) | |
| } | ||
|
|
||
| /*@Override**/ public ProtoIndex rev(Map<String, Object> map) throws DataFormatException { | ||
| long magic = (Long)map.get("serialVersionUID"); | ||
| Object serialVersionUID = map.get("serialVersionUID"); | ||
| long magic; | ||
| if (serialVersionUID instanceof String) { // FIXME | ||
| magic = Long.parseLong((String) map.get("serialVersionUID")); | ||
| } else { | ||
| magic = (Long) serialVersionUID; | ||
| } | ||
|
|
||
| if (magic == ProtoIndex.serialVersionUID) { | ||
| try { | ||
| // FIXME yet more hacks related to the lack of proper asynchronous FreenetArchiver... | ||
| ProtoIndexComponentSerialiser cmpsrl = ProtoIndexComponentSerialiser.get((Integer)map.get("serialFormatUID"), subsrl); | ||
| Object serialFormatUIDObj = map.get("serialFormatUID"); | ||
| int serialFormatUID; | ||
| if (serialFormatUIDObj instanceof String) { // FIXME | ||
| serialFormatUID = Integer.parseInt((String) map.get("serialFormatUID")); | ||
| } else { | ||
| serialFormatUID = (Integer) serialFormatUIDObj; | ||
| } | ||
| ProtoIndexComponentSerialiser cmpsrl = ProtoIndexComponentSerialiser.get(serialFormatUID, subsrl); | ||
| FreenetURI reqID = (FreenetURI)map.get("reqID"); | ||
| String name = (String)map.get("name"); | ||
| String ownerName = (String)map.get("ownerName"); | ||
| String ownerEmail = (String)map.get("ownerEmail"); | ||
| // FIXME yaml idiocy??? It seems to give a Long if the number is big enough to need one, and an Integer otherwise. | ||
| Object totalPagesObj = map.get("totalPages"); | ||
| long totalPages; | ||
| Object o = map.get("totalPages"); | ||
| if(o instanceof Long) | ||
| totalPages = (Long)o; | ||
| else // Integer | ||
| totalPages = (Integer)o; | ||
| Date modified = (Date)map.get("modified"); | ||
| if (totalPagesObj instanceof String) { // FIXME | ||
| totalPages = Long.parseLong((String) totalPagesObj); | ||
| } else if (totalPagesObj instanceof Long) { // FIXME yaml??? It seems to give a Long if the number | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could use |
||
| totalPages = (Long) totalPagesObj; // is big enough to need one, and an Integer otherwise. | ||
| } else { | ||
| totalPages = (Integer) totalPagesObj; | ||
| } | ||
| Object modifiedObj = map.get("modified"); | ||
| Date modified; | ||
| if (modifiedObj instanceof String) { // FIXME | ||
| try { | ||
| modified = new SimpleDateFormat("yyyy-MM-dd").parse((String) modifiedObj); | ||
| } catch (ParseException ignored) { | ||
| modified = null; | ||
| } | ||
| } else { | ||
| modified = (Date) modifiedObj; | ||
| } | ||
| Map<String, Object> extra = (Map<String, Object>)map.get("extra"); | ||
| SkeletonBTreeMap<URIKey, SkeletonBTreeMap<FreenetURI, URIEntry>> utab = utrans.rev((Map<String, Object>)map.get("utab")); | ||
| SkeletonBTreeMap<String, SkeletonBTreeSet<TermEntry>> ttab = ttrans.rev((Map<String, Object>)map.get("ttab")); | ||
| SkeletonBTreeMap<String, SkeletonBTreeSet<TermEntry>> ttab = ttrans.rev((Map<String, Object>) map.get("ttab")); | ||
|
|
||
| return cmpsrl.setSerialiserFor(new ProtoIndex(reqID, name, ownerName, ownerEmail, totalPages, modified, extra, utab, ttab)); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,7 +37,8 @@ public enum EntryType { | |
|
|
||
| public TermEntry(String s, float r) { | ||
| if (s == null) { | ||
| throw new IllegalArgumentException("can't have a null subject!"); | ||
| // throw new IllegalArgumentException("can't have a null subject!"); | ||
| s = "null"; // FIXME | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, this
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably related to https://github.com/freenet/plugin-Library/pull/16/files#diff-aa254c0343e62a1fcd16f7077a106f09R302. Not sure if that gives away a bit more of context.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As far as I can remember this situation, this is about the fact that the subject can contain the human word "null", but then it turns into There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That sounds like something that should be fixed in a different place… but as with the rest of this PR I’m totally not qualified to talk about any of it because I have no clue of all the contexts in question. :) |
||
| } | ||
| if (r < 0/* || r > 1*/) { // FIXME: I don't see how our relevance algorithm can be guaranteed to produce relevance <1. | ||
| throw new IllegalArgumentException("Relevance must be in the half-closed interval (0,1]. Supplied: " + r); | ||
|
|
||
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.
Does everything in this map potentially exist as
String? Where does this map come from?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.
I could write this in the situation when I met a
Stringthere during debugging. Dirty. In my opinion it starts with "snakeyaml implicit resolver", which I turned off as a result.