Package com.ning.tr13

Examples of com.ning.tr13.TrieLookups$ByteBufferAllocator


    {
        TrieHeader header = _readHeader(in, true);
        int len = (int) header.getPayloadLength();
        byte[] buffer = new byte[len];
        InputUtil.readFully(in, buffer, 0, len);
        return new ByteArrayVIntTrieLookup(buffer);
    }
View Full Code Here


    public void testSimpleUsingByteBuffer() throws Exception
    {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        new SimpleVIntTrieBuilder(new MapReader(TEST_ENTRIES)).buildAndWrite(out, false);
        byte[] raw = out.toByteArray();
        _testSimple(new ByteBufferVIntTrieLookup(ByteBuffer.wrap(raw), raw.length));
    }
View Full Code Here

     */
    public static VIntTrieLookup constructByteBufferVIntTrie(byte[] raw,
            ByteBufferAllocator a)
    {
      ByteBuffer bb = _arrayToBuffer(raw, a);
        return new ByteBufferVIntTrieLookup(bb, raw.length);
    }
View Full Code Here

                throw new IOException("Unexpected end-of-stream: still needed to read "+len+" bytes");
            }
            bb.put(buffer, 0, count);
            len -= count;
        }
        return new ByteBufferVIntTrieLookup(bb, len);
    }
View Full Code Here

        return result;
  }
 
  private byte[] loadRawTrie() throws IOException
  {
      SimpleVIntTrieBuilder b = new SimpleVIntTrieBuilder(new VIntValueReader(_file));
      // To re-order or not? Reordering can increase speed slightly (5-10%)
      b.setReorderEntries(true);
      return b.build().serialize();
  }
View Full Code Here

    public VIntTrieLookupTest() { }
   
    public void testSimpleUsingByteBuffer() throws Exception
    {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        new SimpleVIntTrieBuilder(new MapReader(TEST_ENTRIES)).buildAndWrite(out, false);
        byte[] raw = out.toByteArray();
        _testSimple(new ByteBufferVIntTrieLookup(ByteBuffer.wrap(raw), raw.length));
    }
View Full Code Here

    }

    public void testSimpleUsingByteArray() throws Exception
    {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        new SimpleVIntTrieBuilder(new MapReader(TEST_ENTRIES)).buildAndWrite(out, false);
        byte[] raw = out.toByteArray();
        _testSimple(new ByteArrayVIntTrieLookup(raw));
    }
View Full Code Here

    return rt.totalMemory() - rt.freeMemory();
  }
 
  private HashMap<String,Integer> loadMap() throws Exception
  {
        VIntValueReader kr = new VIntValueReader(_file);
        final HashMap<String,Integer> result = new HashMap<String,Integer>();
       
        kr.readAll(new KeyValueReader.ValueCallback<Long>() {
            @Override
            public void handleEntry(byte[] key, Long value) {
              // platform-dependant is ok; only have ascii chars:
              result.put(new String(key), Integer.valueOf(value.intValue()));
            }
View Full Code Here

        return result;
  }
 
  private byte[] loadRawTrie() throws IOException
  {
      SimpleVIntTrieBuilder b = new SimpleVIntTrieBuilder(new VIntValueReader(_file));
      // To re-order or not? Reordering can increase speed slightly (5-10%)
      b.setReorderEntries(true);
      return b.build().serialize();
  }
View Full Code Here

     */

    public static BytesTrieLookup readByteArrayBytesTrie(File f) throws IOException
    {
        FileInputStream fis = new FileInputStream(f);
        BytesTrieLookup trie = readByteArrayBytesTrie(fis);
        fis.close();
        return trie;
    }
View Full Code Here

TOP

Related Classes of com.ning.tr13.TrieLookups$ByteBufferAllocator

Copyright © 2018 www.massapicom. 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.