Package com.persistit

Examples of com.persistit.Exchange


   */
  public Iterable<V> values(Object firstKey, Object secondKey) {
    try {
      exchange.clear();
      exchange.append(firstKey).append(secondKey).append(Key.BEFORE);
      Exchange iteratorExchange = new Exchange(exchange);
      KeyFilter filter = new KeyFilter().append(KeyFilter.simpleTerm(firstKey)).append(KeyFilter.simpleTerm(secondKey));
      return new ValueIterable<V>(iteratorExchange, filter);
    } catch (Exception e) {
      throw failToGetValues(e);
    }
View Full Code Here


   */
  public Iterable<V> values(Object firstKey) {
    try {
      exchange.clear();
      exchange.append(firstKey).append(Key.BEFORE);
      Exchange iteratorExchange = new Exchange(exchange);
      KeyFilter filter = new KeyFilter().append(KeyFilter.simpleTerm(firstKey));
      return new ValueIterable<V>(iteratorExchange, filter);
    } catch (Exception e) {
      throw failToGetValues(e);
    }
View Full Code Here

   * Lazy-loading values
   */
  public Iterable<V> values() {
    try {
      exchange.clear().append(Key.BEFORE);
      Exchange iteratorExchange = new Exchange(exchange);
      KeyFilter filter = new KeyFilter().append(KeyFilter.ALL);
      return new ValueIterable<V>(iteratorExchange, filter);
    } catch (Exception e) {
      throw failToGetValues(e);
    }
View Full Code Here

  }

  public Iterable<Entry<V>> entries() {
    exchange.clear().to(Key.BEFORE);
    KeyFilter filter = new KeyFilter().append(KeyFilter.ALL);
    return new EntryIterable<V>(new Exchange(exchange), filter);
  }
View Full Code Here

  }

  public Iterable<Entry<V>> entries(Object firstKey) {
    exchange.clear().append(firstKey).append(Key.BEFORE);
    KeyFilter filter = new KeyFilter().append(KeyFilter.simpleTerm(firstKey));
    return new EntryIterable<V>(new Exchange(exchange), filter);
  }
View Full Code Here

  public <V> Cache<V> createCache(String cacheName) {
    Preconditions.checkState(volume != null && volume.isOpened(), "Caches are not initialized");
    Preconditions.checkState(!cacheNames.contains(cacheName), "Cache is already created: " + cacheName);
    try {
      Exchange exchange = persistit.getExchange(volume, cacheName, true);
      exchange.setMaximumValueSize(Value.MAXIMUM_SIZE);
      Cache<V> cache = new Cache<V>(cacheName, exchange);
      cacheNames.add(cacheName);
      return cache;
    } catch (Exception e) {
      throw new IllegalStateException("Fail to create cache: " + cacheName, e);
View Full Code Here

        private boolean isExpanded() {
            return true;
        }

        private Row getNextRow(boolean forward) throws PersistitException {
            Exchange ex = setupExchange();
            boolean expanded = (isExpanded());
            if (!ex.traverse(forward ? Key.GT : Key.LT, expanded)) {
                return null;
            }
            Key key = ex.getKey();
            if (key.compareKeyFragment(_rootKey, 0, _rootKey.getEncodedSize()) != 0) {
                return null;
            }
            int keyBytesSize = key.getEncodedSize() - _rootKey.getEncodedSize();
            byte[] keyBytes = new byte[keyBytesSize];
View Full Code Here

            return new Row(keyBytes);
        }

        private String getValueTypeString() {
            try {
                Exchange ex = setupExchange();
                if (ex.getKey().getEncodedSize() == 0)
                    return "";
                ex.fetch();
                Value value = ex.getValue();
                if (!value.isDefined())
                    return "undefined";
                return value.getType().getName();
            } catch (PersistitException de) {
                return de.toString();
View Full Code Here

            }
        }

        private String getValueString() {
            try {
                Exchange ex = setupExchange();
                if (ex.getKey().getEncodedSize() == 0)
                    return "";
                ex.fetch();
                Value value = ex.getValue();
                if (value.getEncodedSize() > 50000) {
                    return "Too long to display: " + value.getEncodedSize();
                } else {
                    return value.toString();
                }
View Full Code Here

                return de.toString();
            }
        }

        private Key getKey() {
            Exchange ex = setupExchange();
            return ex.getKey();
        }
View Full Code Here

TOP

Related Classes of com.persistit.Exchange

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.