Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /* Copyright 2014 The Johns Hopkins University Applied Physics Laboratory
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package edu.jhuapl.tinkerpop.tables;
 
 
 import  org.apache.hadoop.io.Text;
 
 
Wrapper around index tables containing properties and values.
 
 public abstract class BaseIndexValuesTableWrapper extends BaseTableWrapper {
 
   protected final Class<? extends ElementelementType;
 
       Class<? extends ElementelementTypeString tableName) {
     super(globalstableName);
     this. = elementType;
   }

  
Return class of this index.

Returns:
 
   public Class<? extends ElementgetElementType() {
     return ;
   }

  
Add the property to this index, if autoindexing is enabled and/or the given key has indexing enabled.

Parameters:
element
key
value
 
   public void setPropertyForIndex(Element elementString keyObject value) {
     setPropertyForIndex(elementkeyvaluefalse);
   }

  
Add the property to this index.

Note that this requires a round-trip to Accumulo to see if the property exists if the provided key has an index. So for best performance, create indices after bulk ingest.

If the force parameter is true, set the property regardless of whether indexing is enabled for the given key. This is needed for IndexableGraph operations.

Parameters:
element
key
value
force
 
   public void setPropertyForIndex(Element elementString keyObject value,
       boolean force) {
     AccumuloGraphUtils.validateProperty(keyvalue);
    if (force || .getConfig().getAutoIndex() ||
        .getIndexedKeys().contains(key)) {
      BatchWriter writer = getWriter();
      Object oldValue = element.getProperty(key);
      if (oldValue != null && !oldValue.equals(value)) {
        Mutators.apply(writernew IndexValueMutator.Delete(elementkeyoldValue));
      }
      Mutators.apply(writernew IndexValueMutator.Add(elementkeyvalue));
      .checkedFlush();
    }
  }

  
Remove property from the index.

Parameters:
element
key
value
  public void removePropertyFromIndex(Element elementString keyObject value) {
    if (value != null) {
      Mutators.apply(getWriter(), new IndexValueMutator.Delete(elementkeyvalue));
      .checkedFlush();
    }
  }

  
Get elements with the key/value pair.

Parameters:
key
value
Returns:
  @SuppressWarnings("unchecked")
  public <T extends ElementCloseableIterable<T> readElementsFromIndex(String keyObject value) {
    Scanner scan = getScanner();
    byte[] id = AccumuloByteSerializer.serialize(value);
    scan.setRange(Range.exact(new Text(id)));
    scan.fetchColumnFamily(new Text(key));
    final ElementIndexParser<? extends AccumuloElementparser =
        Vertex.class.equals() ? new VertexIndexParser() :
          new EdgeIndexParser();
        return new ScannerIterable<T>(scan) {
          @Override
          public T next(PeekingIterator<Entry<Key,Value>> iterator) {
            return (T) parser.parse(Arrays.asList(iterator.next()));
          }      
        };
  }

  
Remove the given element's properties from the index.

Parameters:
element
  public void removeElementFromIndex(Element element) {
    BatchDeleter deleter = null;
    try {
      deleter = getDeleter();
      deleter.setRanges(Collections.singleton(new Range()));
      IteratorSetting is = new IteratorSetting(10, "getEdgeFilter"RegExFilter.class);
      RegExFilter.setRegexs(isnullnull,
          "^"+Pattern.quote(element.getId().toString())+"$"nullfalse);
      deleter.addScanIterator(is);
      deleter.delete();
      deleter.close();
    } catch (Exception e) {
      throw new AccumuloGraphException(e);
    } finally {
      if (deleter != null) {
        deleter.close();
      }
    }
  }
New to GrepCode? Check out our FAQ X