Package java.nio

Examples of java.nio.ByteBuffer.order()


            fis.read(bb.array());
            IntBuffer ib = bb.asIntBuffer();
            boolean swap = (ib.get(2) < 0 || ib.get(2) > MAX_NUM_CLASS_PRUNERS);
            if (swap) {
                bo = ByteOrder.LITTLE_ENDIAN;
                bb.order(bo);
                ib = bb.asIntBuffer();
            }
            int unicharset_size = ib.get(0);
            int NumClasses = ib.get(1);
            int NumClassPruners = ib.get(2);
View Full Code Here


                fis.read(bb.array(), 0, 4);
                NumClasses = ib.get(0);
            }   
            //this.ClassPruner.ensureCapacity(NumClassPruners);
            bb = ByteBuffer.allocate(nShortByteSize * unicharset_size);
            bb.order(bo);
            fis.read(bb.array());
            ShortBuffer sb = bb.asShortBuffer();
            for (int i=0; i<unicharset_size; i++) {
                this.IndexFor[i] = sb.get(i);
            }
View Full Code Here

            ShortBuffer sb = bb.asShortBuffer();
            for (int i=0; i<unicharset_size; i++) {
                this.IndexFor[i] = sb.get(i);
            }
            bb = ByteBuffer.allocate(nIntByteSize * NumClasses);
            bb.order(bo);
            fis.read(bb.array());
            ib = bb.asIntBuffer();
            for (int i=0; i<NumClasses; i++) {
                this.ClassIdFor[i] = ib.get(i);
            }
View Full Code Here

            for (int i=0; i<NumClassPruners; i++) {
                byte[][][][] Pruner =
                        new byte[NUM_CP_BUCKETS][NUM_CP_BUCKETS][NUM_CP_BUCKETS][];
                bb = ByteBuffer.allocate(nIntByteSize * NUM_CP_BUCKETS *
                        NUM_CP_BUCKETS * NUM_CP_BUCKETS * WERDS_PER_CP_VECTOR);
                bb.order(bo);
                fis.read(bb.array());
                ib = bb.asIntBuffer();
                int p = 0;
                for (int j=0; j<NUM_CP_BUCKETS; j++) {
                    for (int k=0; k<NUM_CP_BUCKETS; k++) {
View Full Code Here

    LearntFeature(FileInputStream fis, ByteOrder bo) {
        try {
            final int nIntByteSize = Integer.SIZE / Byte.SIZE;
            ByteBuffer bb = ByteBuffer.allocate(4 +
                    nIntByteSize * WERDS_PER_CONFIG_VEC);
            bb.order(bo);
            fis.read(bb.array());
            this.A = bb.get(0) << 1;
            // Java doesn't have unsigned byte
            this.B = unsignedByteToShort(bb.get(1));
            this.C = bb.get(2) << 9;
View Full Code Here

    this.mnCutoff = nCutoff;
    try {
      final int nIntByteSize = Integer.SIZE / Byte.SIZE;
      final int nShortByteSize = Short.SIZE / Byte.SIZE;
      ByteBuffer bb = ByteBuffer.allocate(nShortByteSize + 2);
      bb.order(bo);
      fis.read(bb.array());
      this.NumProtos = bb.getShort(0);
      short NumProtoSets = LearntFeature.unsignedByteToShort(bb
          .get(nShortByteSize));
      this.NumConfigs = LearntFeature.unsignedByteToShort(bb
View Full Code Here

        // skip 5 ints
        bb = ByteBuffer.allocate(5 * nIntByteSize);
        fis.read(bb.array());
      }
      bb = ByteBuffer.allocate(MAX_NUM_CONFIGS * nShortByteSize);
      bb.order(bo);
      fis.read(bb.array());
      ShortBuffer sb = bb.asShortBuffer();
      for (int i = 0; i < this.ConfigLengths.length; i++) {
        this.ConfigLengths[i] = sb.get(i);
      }
View Full Code Here

      this.ProtoLengths = new short[NumProtoSets
          * Prototype.PROTOS_PER_PROTO_SET];
      Arrays.fill(this.ProtoLengths, (short) 0);
      bb = ByteBuffer.allocate(NumProtoSets
          * Prototype.PROTOS_PER_PROTO_SET);
      bb.order(bo);
      fis.read(bb.array());
      for (int i = 0; i < this.NumProtos; i++) {
        this.ProtoLengths[i] = LearntFeature.unsignedByteToShort(bb.get(i));
      }
      int nProtosLeft = this.NumProtos;
View Full Code Here

    public Prototype(FileInputStream fis, ByteOrder bo, int nProtosToRead) {
        try {
            final int nIntByteSize = Integer.SIZE / Byte.SIZE;
            ByteBuffer bb = ByteBuffer.allocate(nIntByteSize * NUM_PP_PARAMS *
                    NUM_PP_BUCKETS * WERDS_PER_PP_VECTOR);
            bb.order(bo);
            fis.read(bb.array());
            IntBuffer ib = bb.asIntBuffer();
            int p = 0;
            for (int i=0; i<NUM_PP_PARAMS; i++) {
                for (int j=0; j<NUM_PP_BUCKETS; j++) {
View Full Code Here

        final ByteBuffer buf = truncateBuffer(rcvBuf, datalen);
        NIOUtils.readFully(channel, buf, datalen);
        buf.flip();
        if(ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
            buf.order(ByteOrder.BIG_ENDIAN);
        }
        final byte[] b = new byte[datalen];
        buf.get(b);
        if(buf != rcvBuf) {
            _rbufPool.returnObject(buf);
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.