From f133d6065c788f6b540e6ed705a5046688a73a5b Mon Sep 17 00:00:00 2001 From: orbiter Date: Sun, 17 May 2009 18:28:33 +0000 Subject: [PATCH] fix for http://forum.yacy-websuche.de/viewtopic.php?p=14955#p14955 git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5958 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- .../ReferenceContainerConcurrentCache.java | 150 ++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 source/de/anomic/kelondro/text/ReferenceContainerConcurrentCache.java diff --git a/source/de/anomic/kelondro/text/ReferenceContainerConcurrentCache.java b/source/de/anomic/kelondro/text/ReferenceContainerConcurrentCache.java new file mode 100644 index 000000000..8ab2b4d37 --- /dev/null +++ b/source/de/anomic/kelondro/text/ReferenceContainerConcurrentCache.java @@ -0,0 +1,150 @@ +// ReferenceContainerConcurrentCache.java +// (C) 2009 by Michael Peter Christen; mc@yacy.net, Frankfurt a. M., Germany +// first published 05.04.2009 on http://yacy.net +// +// This is a part of YaCy, a peer-to-peer based web search engine +// +// $LastChangedDate: 2009-05-05 22:08:23 +0200 (Di, 05 Mai 2009) $ +// $LastChangedRevision: 5924 $ +// $LastChangedBy: orbiter $ +// +// LICENSE +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +package de.anomic.kelondro.text; + +import de.anomic.kelondro.order.ByteOrder; +import de.anomic.kelondro.index.Row; + +public final class ReferenceContainerConcurrentCache /* extends AbstractIndex implements Index, IndexReader, Iterable>*/ { + + private final Row payloadrow; + private final ByteOrder termOrder; + private ReferenceContainerCache caches[]; + private final int concurrency; + private final ReferenceFactory factory; + + public ReferenceContainerConcurrentCache(final ReferenceFactory factory, final Row payloadrow, ByteOrder termOrder, int concurrency) { + //super(factory); + this.payloadrow = payloadrow; + this.termOrder = termOrder; + this.concurrency = concurrency; + this.caches = null; + this.factory = factory; + } + + public Row rowdef() { + return this.payloadrow; + } + + public void clear() { + if (caches != null) { + for (int i = 0; i < caches.length; i++) { + caches[i].clear(); + caches[i].initWriteMode(); + } + } + } + + public void close() { + if (caches != null) { + for (int i = 0; i < caches.length; i++) { + caches[i].close(); + } + } + this.caches = null; + } + + @SuppressWarnings("unchecked") + public void initWriteMode() { + caches = new ReferenceContainerCache[concurrency]; + for (int i = 0; i < caches.length; i++) { + caches[i] = new ReferenceContainerCache(factory, payloadrow, termOrder); + } + } + + public int size() { + if (caches == null) return 0; + int count = 0; + for (int i = 0; i < caches.length; i++) { + count += caches[i].size(); + } + return count; + } + + public int maxReferences() { + if (caches == null) return 0; + int max = 0; + for (int i = 0; i < caches.length; i++) { + max = Math.max(max, caches[i].maxReferences()); + } + return max; + } + +/* + public synchronized CloneableIterator> references(final byte[] startWordHash, final boolean rot) { + ArrayList>> a = new ArrayList>>(caches.length); + for (int i = 0; i < caches.length; i++) { + a.add(caches[i].references(startWordHash, rot)); + } + return MergeIterator.cascade(a, termOrder, MergeIterator.simpleMerge, true); + } + + public Iterator> iterator() { + return references(null, false); + } + + public boolean has(final byte[] key) { + return this.cache.containsKey(new ByteArray(key)); + } + + public ReferenceContainer get(final byte[] key, Set urlselection) { + + } + + public int count(final byte[] key) { + + } + + public ReferenceContainer delete(final byte[] termHash) { + + } + + public boolean remove(final byte[] termHash, final String urlHash) { + + } + + public int remove(final byte[] termHash, final Set urlHashes) { + + } + + public void add(final ReferenceContainer container) { + + } + + public void add(final byte[] termHash, final ReferenceType newEntry) { + + } + + public int minMem() { + return 0; + } + + public ByteOrder ordering() { + return this.termOrder; + } + */ +}