Class BinaryDataReader

java.lang.Object
es.uam.eps.ir.relison.diffusion.io.BinaryDataReader

public class BinaryDataReader
extends java.lang.Object
Reads data from a binary file.
  • Constructor Summary

    Constructors 
    Constructor Description
    BinaryDataReader()  
  • Method Summary

    Modifier and Type Method Description
    static Data<java.lang.Long,​java.lang.Long,​java.lang.Long> read​(java.lang.String file)
    Read a simple version of the data.
    static Data<java.lang.Long,​java.lang.Long,​java.lang.Long> read​(java.lang.String file, java.lang.String recFile, int topN)
    Read a simple version of the data.
    private static Triplet<java.lang.String,​Index<java.lang.Long>,​Relation<java.lang.Double>> readFeature​(java.io.DataInputStream dos, Index<java.lang.Long> index)
    Reads information about a single feature.
    private static Triplet<java.util.List<java.lang.String>,​java.util.Map<java.lang.String,​Index<java.lang.Long>>,​java.util.Map<java.lang.String,​Relation<java.lang.Double>>> readFeatures​(java.io.DataInputStream dos, Index<java.lang.Long> index)
    Reads information about features.
    private static Triplet<Index<java.lang.Long>,​java.util.Map<java.lang.Integer,​Information<java.lang.Long>>,​Relation<java.lang.Integer>> readInfoPieces​(java.io.DataInputStream dos, Index<java.lang.Long> userIndex)
    Reads about information pieces.
    private static Relation<java.lang.Long> readRealProp​(java.io.DataInputStream dos, Index<java.lang.Long> userIndex, Index<java.lang.Long> infoPiecesIndex)
    Reads information about the real propagated information pieces.
    private static Index<java.lang.Long> readUserIndex​(java.io.DataInputStream dos)
    Reads a user index.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • read

      public static Data<java.lang.Long,​java.lang.Long,​java.lang.Long> read​(java.lang.String file)
      Read a simple version of the data.
      Parameters:
      file - the file containing the data.
      Returns:
      a Data object if ok, null if not.
    • read

      public static Data<java.lang.Long,​java.lang.Long,​java.lang.Long> read​(java.lang.String file, java.lang.String recFile, int topN)
      Read a simple version of the data.
      Parameters:
      file - the file containing the data.
      recFile - File containing the recommendation.
      topN - the number of recommendations to take.
      Returns:
      a Data object if ok, null if not.
    • readUserIndex

      private static Index<java.lang.Long> readUserIndex​(java.io.DataInputStream dos) throws java.io.IOException
      Reads a user index.
      Parameters:
      dos - A data stream for reading the data.
      Returns:
      the user index.
      Throws:
      java.io.IOException - if something fails while reading the data stream.
    • readInfoPieces

      private static Triplet<Index<java.lang.Long>,​java.util.Map<java.lang.Integer,​Information<java.lang.Long>>,​Relation<java.lang.Integer>> readInfoPieces​(java.io.DataInputStream dos, Index<java.lang.Long> userIndex) throws java.io.IOException
      Reads about information pieces.
      Parameters:
      dos - A data stream for reading the data.
      userIndex - The index for the users.
      Returns:
      a triplet containing the index of information pieces, the additional information for those pieces and the user-piece relation.
      Throws:
      java.io.IOException - if something fails while reading the data stream.
    • readFeatures

      private static Triplet<java.util.List<java.lang.String>,​java.util.Map<java.lang.String,​Index<java.lang.Long>>,​java.util.Map<java.lang.String,​Relation<java.lang.Double>>> readFeatures​(java.io.DataInputStream dos, Index<java.lang.Long> index) throws java.io.IOException
      Reads information about features.
      Parameters:
      dos - a data stream for reading the data.
      index - an index (user/pieces).
      Returns:
      a triplet containing the list of parameter names, a map containing the possible values for each parameter, a map containing the relation between users and information pieces.
      Throws:
      java.io.IOException - if something fails while reading the data stream.
    • readFeature

      private static Triplet<java.lang.String,​Index<java.lang.Long>,​Relation<java.lang.Double>> readFeature​(java.io.DataInputStream dos, Index<java.lang.Long> index) throws java.io.IOException
      Reads information about a single feature.
      Parameters:
      dos - a data stream for reading the data.
      index - an index (user/pieces).
      Returns:
      a triplet containing the name of the parameter, the possible values for the parameter, the relation between users and values.
      Throws:
      java.io.IOException - if something fails while reading the data stream.
    • readRealProp

      private static Relation<java.lang.Long> readRealProp​(java.io.DataInputStream dos, Index<java.lang.Long> userIndex, Index<java.lang.Long> infoPiecesIndex) throws java.io.IOException
      Reads information about the real propagated information pieces.
      Parameters:
      dos - the data stream for reading the data.
      userIndex - the user index.
      infoPiecesIndex - the information pieces index.
      Returns:
      the relation between user pieces and repropagated information pieces (containing its timestamps as weights)
      Throws:
      java.io.IOException - if something fails while reading the pieces.