Package net.yacy.kelondro.util

Examples of net.yacy.kelondro.util.ByteArray


     */
    private void enqueueContainersToCloud(final List<ReferenceContainer<WordReference>>[] containers) {
        if (this.transmissionCloud == null) return;
        ReferenceContainer<WordReference> lastContainer;
        byte[] primaryTarget;
        ByteArray pTArray;
        Transmission.Chunk entry;
        for (int vertical = 0; vertical < containers.length; vertical++) {
            // the 'new' primary target is the word hash of the last container in the array
            lastContainer = containers[vertical].get(containers[vertical].size() - 1);
            primaryTarget = FlatWordPartitionScheme.positionToHash(this.seeds.scheme.dhtPosition(lastContainer.getTermHash(), vertical));
            assert primaryTarget[2] != '@';
            pTArray = new ByteArray(primaryTarget);

            // get or make a entry object
            entry = this.transmissionCloud.get(pTArray); // if this is not null, the entry is extended here
            final List<yacySeed> targets = PeerSelection.getAcceptRemoteIndexSeedsList(
                    this.seeds,
View Full Code Here


     * This method returns true if a container was dequeued, false if not
     */
    public boolean dequeueContainer() {
      if (this.transmissionCloud == null) return false;
        if (this.indexingTransmissionProcessor.queueSize() > this.indexingTransmissionProcessor.concurrency()) return false;
        ByteArray maxtarget = null;
        int maxsize = -1;
        for (final Map.Entry<ByteArray, Transmission.Chunk> chunk: this.transmissionCloud.entrySet()) {
            if (chunk.getValue().containersSize() > maxsize) {
                maxsize = chunk.getValue().containersSize();
                maxtarget = chunk.getKey();
View Full Code Here

        // test ByteArray
        System.out.println("unsorted map");
        Runtime.getRuntime().gc();
        final long freeStartBA = MemoryControl.available();
        HashMap<ByteArray, Integer> bm = new HashMap<ByteArray, Integer>();
        for (int i = 0; i < count; i++) bm.put(new ByteArray(tests[i]), 1);
        final long t8 = System.currentTimeMillis();
        System.out.println("time   for HashMap<ByteArray> generation: " + (t8 - t7));
       
        bugs = 0;
        for (int i = 0; i < count; i++) if (bm.get(new ByteArray(tests[i])) == null) bugs++;
        Runtime.getRuntime().gc();
        final long freeEndBA = MemoryControl.available();
        bm.clear(); bm = null;
        final long t9 = System.currentTimeMillis();
        System.out.println("time   for HashMap<ByteArray> test: " + (t9 - t8) + ", " + bugs + " bugs");
View Full Code Here

     * this works with heaps in write- and read-mode
     * @param key
     * @return true, if the key is used in the heap; false otherwise
     */
    public boolean has(final byte[] key) {
        return this.cache.containsKey(new ByteArray(key));
    }
View Full Code Here

     * @param key
     * @return the indexContainer if one exist, null otherwise
     * @throws
     */
    public ReferenceContainer<ReferenceType> get(final byte[] key, final HandleSet urlselection) {
        final ReferenceContainer<ReferenceType> c = this.cache.get(new ByteArray(key));
        if (urlselection == null) return c;
        if (c == null) return null;
        // because this is all in RAM, we must clone the entries (flat)
        try {
            final ReferenceContainer<ReferenceType> c1 = new ReferenceContainer<ReferenceType>(this.factory, c.getTermHash(), c.size());
View Full Code Here

     * return the size of the container with corresponding key
     * @param key
     * @return
     */
    public int count(final byte[] key) {
        final ReferenceContainer<ReferenceType> c = this.cache.get(new ByteArray(key));
        if (c == null) return 0;
        return c.size();
    }
View Full Code Here

     */
    public ReferenceContainer<ReferenceType> delete(final byte[] termHash) {
        // returns the index that had been deleted
        assert this.cache != null;
        if (this.cache == null) return null;
        return this.cache.remove(new ByteArray(termHash));
    }
View Full Code Here

        remove(termHash, urlHashBytes);
    }
    public boolean remove(final byte[] termHash, final byte[] urlHashBytes) {
        assert this.cache != null;
        if (this.cache == null) return false;
        final ByteArray tha = new ByteArray(termHash);
        synchronized (this.cache) {
          final ReferenceContainer<ReferenceType> c = this.cache.get(tha);
          if (c != null && c.delete(urlHashBytes)) {
              // removal successful
              if (c.isEmpty()) {
View Full Code Here

    public int remove(final byte[] termHash, final HandleSet urlHashes) {
        assert this.cache != null;
        if (this.cache == null) return  0;
        if (urlHashes.isEmpty()) return 0;
        final ByteArray tha = new ByteArray(termHash);
        int count;
        synchronized (this.cache) {
            final ReferenceContainer<ReferenceType> c = this.cache.get(tha);
            if ((c != null) && ((count = c.removeEntries(urlHashes)) > 0)) {
                // removal successful
View Full Code Here

    public void add(final ReferenceContainer<ReferenceType> container) throws RowSpaceExceededException {
        // this puts the entries into the cache
        if (this.cache == null || container == null || container.isEmpty()) return;

        // put new words into cache
        final ByteArray tha = new ByteArray(container.getTermHash());
        int added = 0;
        synchronized (this.cache) {
            ReferenceContainer<ReferenceType> entries = this.cache.get(tha); // null pointer exception? wordhash != null! must be cache==null
            if (entries == null) {
                entries = container.topLevelClone();
View Full Code Here

TOP

Related Classes of net.yacy.kelondro.util.ByteArray

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.