Exemplo n.º 1
0
 /*
  * (non-Javadoc)
  *
  * @see hdt.triples.array.Stream#save(java.io.OutputStream)
  */
 @Override
 public void save(OutputStream output, ProgressListener listener) throws IOException {
   output.write(SequenceFactory.TYPE_SEQ32);
   IOUtil.writeInt(output, numelements);
   for (int i = 0; i < numelements; i++) {
     IOUtil.writeInt(output, data[i]);
   }
 }
Exemplo n.º 2
0
  /*
   * (non-Javadoc)
   *
   * @see hdt.triples.array.Stream#load(java.io.InputStream)
   */
  @Override
  public void load(InputStream input, ProgressListener listener) throws IOException {
    int type = input.read();
    if (type != SequenceFactory.TYPE_SEQ32) {
      throw new IllegalFormatException("Trying to read INT32 but data is not INT32");
    }

    int size = IOUtil.readInt(input);
    if (size < 0) {
      throw new IOException("Cannot load values bigger than 2Gb with this data structure");
    }

    numelements = 0;
    data = new int[size];

    for (long i = 0; i < size; i++) {
      append(IOUtil.readInt(input));
    }
  }
Exemplo n.º 3
0
 @Override
 public boolean readAndCheck(InputStream in) throws IOException {
   int readCRC = IOUtil.readShort(in) & 0xFFFF;
   return (readCRC == crc16);
 }
Exemplo n.º 4
0
 @Override
 public void writeCRC(OutputStream out) throws IOException {
   IOUtil.writeShort(out, (short) crc16);
 }