Package java.io

Examples of java.io.DataInputStream.readUTF()


 
  static Trie loadTrie(String path) throws IOException {
    Trie trie;
    DataInputStream is = new DataInputStream(new BufferedInputStream(
        new FileInputStream(path)));
    String method = is.readUTF().toUpperCase(Locale.ROOT);
    if (method.indexOf('M') < 0) {
      trie = new Trie(is);
    } else {
      trie = new MultiTrie(is);
    }
View Full Code Here


        // to reduce empty table space
        Map<String,SemanticVector> wordToSemantics =
            new HashMap<String,SemanticVector>(words, 2f);

        for (int wordIndex = 0; wordIndex < words; ++wordIndex) {
            String word = dis.readUTF();
            int timeSteps = dis.readInt();
            SemanticVector vector = new SemanticVector(dimensions);
            wordToSemantics.put(word, vector);

            LOGGER.info("loading " + timeSteps +
View Full Code Here

        // to reduce empty table space
        Map<String,SemanticVector> wordToSemantics =
            new HashMap<String,SemanticVector>(words, 2f);

        for (int wordIndex = 0; wordIndex < words; ++wordIndex) {
            String word = dis.readUTF();
            int timeSteps = dis.readInt();
            SemanticVector vector = new SemanticVector(dimensions);
            wordToSemantics.put(word, vector);

            LOGGER.info("loading " + timeSteps +
View Full Code Here

        // create a dense matrix
        Matrix m = new ArrayMatrix(rows, cols);
        double[] d = new double[cols];
        for (int row = 0; row < rows; ++row) {
            String word = dis.readUTF();
            termToIndex.put(word, row);

            for (int col = 0; col < cols; ++col) {
                d[col] = dis.readDouble();
            }
View Full Code Here

        // allocate the indices values at once, rather than pay the log(n)
        // overhead of sorting them
        CompactSparseVector[] rowVectors = new CompactSparseVector[rows];

        for (int row = 0; row < rows; ++row) {
            String word = dis.readUTF();
            termToIndex.put(word, row);
           
            int nonZero = dis.readInt();
            int[] indices = new int[nonZero];
            double[] values = new double[nonZero];
View Full Code Here

             *   u1 tag;
             *   u2 length;
             *   u1 bytes[length];
             * }
             */
            String str = in.readUTF();

            // check if this string sounds interesting
            if (containsFieldDescriptor(str))
            {
               if (log.isTraceEnabled())
View Full Code Here

        try {
            this.opCode = inputStream.readByte();
            switch(opCode) {
                case VoldemortOpCode.GET_OP_CODE:
                    this.version = null;
                    this.key = inputStream.readUTF();
                    this.value = null;
                    break;
                case VoldemortOpCode.PUT_OP_CODE:
                    this.version = new VectorClock(bytes, 1);
                    this.key = inputStream.readUTF();
View Full Code Here

                    this.key = inputStream.readUTF();
                    this.value = null;
                    break;
                case VoldemortOpCode.PUT_OP_CODE:
                    this.version = new VectorClock(bytes, 1);
                    this.key = inputStream.readUTF();
                    int valueSize = inputStream.readInt();
                    this.value = new byte[valueSize];
                    ByteUtils.read(inputStream, this.value);
                    break;
                case VoldemortOpCode.DELETE_OP_CODE:
View Full Code Here

                    this.value = new byte[valueSize];
                    ByteUtils.read(inputStream, this.value);
                    break;
                case VoldemortOpCode.DELETE_OP_CODE:
                    this.version = new VectorClock(bytes, 1);
                    this.key = inputStream.readUTF();
                    this.value = null;
                    break;
                default:
                    throw new SerializationException("Unknown opcode: " + bytes[0]);
            }
View Full Code Here

    this(type, arg1, "");
  }

  public HadoopFrameworkMessage(byte[] bytes) throws IOException {
    DataInputStream in = new DataInputStream(new ByteArrayInputStream(bytes));
    String typeStr = in.readUTF();
    try {
      type = Type.valueOf(typeStr);
    } catch(IllegalArgumentException e) {
      throw new IOException("Unknown message type: " + typeStr);
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.