예제 #1
0
  private void writeVersion2(final ObjectOutput out) throws IOException {

    assert iv2val.size() == val2iv.size();

    // compute a checksum on the hash codes of the URIs.
    long checksum = 0;
    for (Value value : val2iv.keySet()) {
      checksum += value.hashCode();
    }

    // write on the #of declarations.
    LongPacker.packLong(out, decls.size());

    // write on the #of values.
    LongPacker.packLong(out, val2iv.size());

    // write out the checksum.
    out.writeLong(checksum);

    // The namespace of the KB instance.
    out.writeUTF(valueFactory.getNamespace());

    //        for (VocabularyDecl decl : decls) {
    //
    //            // The class name of the vocabulary declaration.
    //            out.writeUTF(decl.getClass().getName());
    //
    //        }

  }
예제 #2
0
 @Override
 public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
   queryId = new UUID(in.readLong() /* MSB */, in.readLong() /* LSB */);
   serviceId = new UUID(in.readLong() /* MSB */, in.readLong() /* LSB */);
   bopId = in.readInt();
   partitionId = in.readInt();
   sinkMessagesOut = LongPacker.unpackInt(in);
   altSinkMessagesOut = LongPacker.unpackInt(in);
   //        sinkMessagesOut = in.readInt();
   //        altSinkMessagesOut = in.readInt();
   stats = (BOpStats) in.readObject();
   cause = (Throwable) in.readObject();
 }
예제 #3
0
 @Override
 public void writeExternal(final ObjectOutput out) throws IOException {
   out.writeLong(queryId.getMostSignificantBits());
   out.writeLong(queryId.getLeastSignificantBits());
   out.writeLong(serviceId.getMostSignificantBits());
   out.writeLong(serviceId.getLeastSignificantBits());
   out.writeInt(bopId);
   out.writeInt(partitionId); // Note: partitionId is 32-bits clean
   LongPacker.packLong(out, sinkMessagesOut);
   LongPacker.packLong(out, altSinkMessagesOut);
   //        out.writeInt(sinkMessagesOut);
   //        out.writeInt(altSinkMessagesOut);
   out.writeObject(stats);
   out.writeObject(cause);
 }
예제 #4
0
  private void readVersion2(final ObjectInput in) throws IOException {

    // read in the #of declarations.
    final int ndecls = LongPacker.unpackInt(in);

    // read in the #of values.
    final int nvalues = LongPacker.unpackInt(in);

    // read in the checksum.
    final long checksumActual = in.readLong();

    // The namespace of the KB instance.
    final String namespace = in.readUTF();

    // Note: The value factory uses the namespace of the KB instance!
    valueFactory = BigdataValueFactoryImpl.getInstance(namespace);

    // Initialize the vocabulary.
    init(ndecls, nvalues);

    //        decls = new LinkedHashSet<VocabularyDecl>(ndecls);
    //
    //        // allocate the map with sufficient capacity.
    //        val2iv = new LinkedHashMap<Value, BigdataValue>(nvalues);
    //        iv2val = new LinkedHashMap<IV, BigdataValue>(nvalues);
    //
    //        for (int i = 0; i < ndecls; i++) {
    //
    //            final String className = in.readUTF();
    //
    //            try {
    //
    //                final Class<?> cls = Class.forName(className);
    //
    //                if (!VocabularyDecl.class.isAssignableFrom(cls))
    //                    throw new IOException(className);
    //
    //                final VocabularyDecl decl = (VocabularyDecl) cls.newInstance();
    //
    //                decls.add(decl);
    //
    //            } catch (InstantiationException e) {
    //
    //                throw new IOException(e);
    //
    //            } catch (IllegalAccessException e) {
    //
    //                throw new IOException(e);
    //
    //            } catch (ClassNotFoundException e) {
    //
    //                throw new IOException(e);
    //
    //            }
    //
    //        }
    //
    //        addAllDecls();

    if (ndecls != decls.size()) {
      /*
       * This indicates a versioning problem with the vocabulary
       * declaration classes.
       */
      throw new IOException();
    }

    if (nvalues != val2iv.size()) {
      /*
       * This indicates a versioning problem with the vocabulary
       * declaration classes.
       */
      throw new VocabularyVersioningException();
    }

    // compute a checksum on the hash codes of the URIs.
    long checksum = 0;
    for (Value value : val2iv.keySet()) {
      checksum += value.hashCode();
    }

    if (checksum != checksumActual) {
      /*
       * This indicates a versioning problem with the vocabulary
       * declaration classes.
       */
      throw new VocabularyVersioningException();
    }

    generateIVs();
  }