congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
IndexDefinition
Code IndexAdd Tabnine to your IDE (free)

How to use
IndexDefinition
in
com.oberasoftware.jasdb.api.model

Best Java code snippets using com.oberasoftware.jasdb.api.model.IndexDefinition (Showing top 15 results out of 315)

origin: oberasoftware/jasdb

public static IndexEntry map(IndexDefinition definition, boolean isUnique) {
  return new IndexEntry(definition.getIndexName(), definition.getHeaderDescriptor(), definition.getValueDescriptor(), isUnique, definition.getIndexType());
}
origin: oberasoftware/jasdb

  @Override
  public String toString() {
    return toHeader();
  }
}
origin: oberasoftware/jasdb

public static IndexDefinition fromHeader(String header) throws MetadataParseException {
  String[] definitionSections = header.split("/");
  if(definitionSections.length == 4) {
    try {
      String indexName = definitionSections[0];
      String headerDescriptor = definitionSections[1];
      String valueDescriptor = definitionSections[2];
      int indexType = Integer.parseInt(definitionSections[3]);
      return new IndexDefinition(indexName, headerDescriptor, valueDescriptor, indexType);
    } catch(NumberFormatException e) {
      throw new MetadataParseException("Unable to get index type for heade: " + header);
    }
  } else {
    throw new MetadataParseException("Unable to parse index metadata section");
  }
}
origin: oberasoftware/jasdb

@Override
public List<String> getIndexNames() throws JasDBStorageException {
  BagConnector connector = RemoteConnectorFactory.createConnector(nodeInformation, BagConnector.class);
  List<IndexDefinition> indexDefinitions = connector.getIndexDefinitions(context, instance, meta.getName());
  List<String> indexNames = new ArrayList<>(indexDefinitions.size());
  for(IndexDefinition definition : indexDefinitions) {
    indexNames.add(definition.getIndexName());
  }
  return indexNames;
}
origin: oberasoftware/jasdb

public static BagMeta fromEntity(Entity entity) throws JasDBStorageException {
  String instance = entity.getValue(Constants.INSTANCE).toString();
  String name = entity.getValue(Constants.NAME).toString();
  List<IndexDefinition> indexDefinitionList = new ArrayList<>();
  if(entity.hasProperty(Constants.INDEXES)) {
    for(Object indexDefinition : entity.getValues(Constants.INDEXES)) {
      indexDefinitionList.add(IndexDefinition.fromHeader(indexDefinition.toString()));
    }
  }
  return new BagMeta(instance, name, indexDefinitionList);
}
origin: oberasoftware/jasdb

  public static IndexDefinition map(IndexEntry entry) {
    return new IndexDefinition(entry.getName(), entry.getKeyHeader(), entry.getValueHeader(), entry.getIndexType());
  }
}
origin: oberasoftware/jasdb

@Override
public boolean equals(Object o) {
  if(o instanceof IndexDefinition) {
    IndexDefinition other = (IndexDefinition) o;
    if(other.getHeaderDescriptor().equals(headerDescriptor)
        && other.getValueDescriptor().equals(valueDescriptor)
        && other.getIndexName().equals(indexName)
        && other.getIndexType() == indexType) {
      return true;
    }
  }
  return false;
}
origin: oberasoftware/jasdb

@Override
public void removeIndex(String bagName, String keyName) throws JasDBStorageException {
  Index index = getIndex(bagName, keyName);
  if(index != null) {
    Map<String, Index> bagIndexes = indexes.get(bagName);
    bagIndexes.remove(keyName);
    KeyInfo keyInfo = index.getKeyInfo();
    IndexDefinition definition = new IndexDefinition(keyInfo.getKeyName(), keyInfo.keyAsHeader(), keyInfo.valueAsHeader(), index.getIndexType());
    metadataStore.removeBagIndex(instanceId, bagName, definition);
    index.removeIndex();
  } else {
    throw new JasDBStorageException("Could not remove index, does not exist");
  }
}
origin: oberasoftware/jasdb

@Override
public int hashCode() {
  return toHeader().hashCode();
}
origin: oberasoftware/jasdb

private Index loadIndex(String bagName, IndexDefinition indexDefinition) throws JasDBStorageException {
  try {
    KeyInfo keyInfo = new KeyInfoImpl(indexDefinition.getHeaderDescriptor(), indexDefinition.getValueDescriptor());
    File indexFile = createIndexFile(bagName, indexDefinition.getIndexName(), false);
    switch(IndexTypes.getTypeFor(indexDefinition.getIndexType())) {
      case BTREE:
        LOG.debug("Loaded BTree Index for key: {}", indexDefinition.getIndexName());
        Index btreeIndex = new BTreeIndex(indexFile, keyInfo);
        return configureIndex(IndexTypes.BTREE, btreeIndex);
      default:
        throw new JasDBStorageException("Reading from this index type: " + indexDefinition.getIndexName() +
            " is not supported");
    }
  } catch(ConfigurationException e) {
    throw new JasDBStorageException("Unable to load index, invalid configuration", e);
  }
}
origin: oberasoftware/jasdb

@Override
public void ensureIndex(CompositeIndexField queryFields, boolean isUnique, IndexField... valueFields) throws JasDBStorageException {
  BagConnector connector = RemoteConnectorFactory.createConnector(nodeInformation, BagConnector.class);
  KeyInfo keyInfo = new KeyInfoImpl(queryFields.getIndexFields(), Lists.newArrayList(valueFields));
  connector.createIndex(context, instance, meta.getName(),
      new IndexDefinition(keyInfo.getKeyName(), keyInfo.keyAsHeader(), keyInfo.valueAsHeader(), -1), isUnique);
}
origin: oberasoftware/jasdb

public static SimpleEntity toEntity(Bag bag) throws JasDBStorageException {
  SimpleEntity entity = new SimpleEntity();
  entity.addProperty(Constants.META_TYPE, Constants.BAG_TYPE);
  entity.addProperty(Constants.INSTANCE, bag.getInstanceId());
  entity.addProperty(Constants.NAME, bag.getName());
  for(IndexDefinition indexDefinition : bag.getIndexDefinitions()) {
    entity.addProperty(Constants.INDEXES, indexDefinition.toHeader());
  }
  return entity;
}
origin: oberasoftware/jasdb

private void initializeIndex(Index index) throws JasDBStorageException {
  KeyInfo keyInfo = index.getKeyInfo();
  IndexDefinition definition = new IndexDefinition(keyInfo.getKeyName(), keyInfo.keyAsHeader(), keyInfo.valueAsHeader(), index.getIndexType());
  if(metadataStore.containsIndex(instanceId, bagName, definition)) {
    try {
      indexRebuilder.submit(new IndexScanAndRecovery(index, getRecordWriter().readAllRecords(), true)).get();
    } catch(ExecutionException | InterruptedException e) {
      throw new JasDBStorageException("Unable to initialize index, index rebuild failed", e);
    }
  } else {
    throw new JasDBStorageException("Cannot initialize index, does not exist in store");
  }
}
origin: oberasoftware/jasdb

private Index createInStore(String bagName, KeyInfo keyInfo) throws JasDBStorageException {
  if(!indexes.containsKey(bagName)) {
    loadIndexes(bagName);
  }
  Map<String, Index> bagIndexes = this.indexes.get(bagName);
  if(bagIndexes != null && !bagIndexes.containsKey(keyInfo.getKeyName())) {
    File indexFile = createIndexFile(bagName, keyInfo.getKeyName(), false);
    try {
      Index index = new BTreeIndex(indexFile, keyInfo);
      configureIndex(IndexTypes.BTREE, index);
      IndexDefinition definition = new IndexDefinition(keyInfo.getKeyName(), keyInfo.keyAsHeader(), keyInfo.valueAsHeader(), index.getIndexType());
      metadataStore.addBagIndex(instanceId, bagName, definition);
      bagIndexes.put(keyInfo.getKeyName(), index);
      return index;
    } catch(ConfigurationException e) {
      throw new JasDBStorageException("Unable to create index, configuration error", e);
    }
  } else if(bagIndexes != null){
    return bagIndexes.get(keyInfo.getKeyName());
  } else {
    return null;
  }
}
origin: oberasoftware/jasdb

@Override
public void ensureIndex(IndexField indexField, boolean isUnique, IndexField... valueFields) throws JasDBStorageException {
  BagConnector connector = RemoteConnectorFactory.createConnector(nodeInformation, BagConnector.class);
  KeyInfo keyInfo = new KeyInfoImpl(indexField, valueFields);
  connector.createIndex(context, instance, meta.getName(),
      new IndexDefinition(keyInfo.getKeyName(), keyInfo.keyAsHeader(), keyInfo.valueAsHeader(), -1), isUnique);
}
com.oberasoftware.jasdb.api.modelIndexDefinition

Most used methods

  • <init>
  • getIndexName
  • getHeaderDescriptor
  • getIndexType
  • getValueDescriptor
  • toHeader
  • fromHeader

Popular in Java

  • Making http requests using okhttp
  • putExtra (Intent)
  • getResourceAsStream (ClassLoader)
  • onRequestPermissionsResult (Fragment)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • JFileChooser (javax.swing)
  • JList (javax.swing)
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now