Tabnine Logo
com.oberasoftware.jasdb.core.index.query
Code IndexAdd Tabnine to your IDE (free)

How to use com.oberasoftware.jasdb.core.index.query

Best Java code snippets using com.oberasoftware.jasdb.core.index.query (Showing top 20 results out of 315)

origin: oberasoftware/jasdb

private SearchCondition handleEqualsToRange(EqualsCondition equalsCondition) {
  int nrOfKeys = keyInfo.getKeyFields().size();
  if(nrOfKeys > 1) {
    //composite keys always use range search
    return new RangeCondition(equalsCondition.getKey(), true, equalsCondition.getKey(), true);
  } else {
    return equalsCondition;
  }
}
origin: oberasoftware/jasdb

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

@Override
public Key next() {
  return hasNext() ? keyIterator.next() : null;
}
origin: oberasoftware/jasdb

@Override
public SearchCondition mergeCondition(KeyNameMapper nameMapper, String sourceField, String mergeField, SearchCondition condition) {
  if(condition instanceof EqualsCondition) {
    CompositeKey compositeKey;
    if(key instanceof CompositeKey) {
      compositeKey = (CompositeKey) key;
    } else {
      compositeKey = new CompositeKey();
      compositeKey.addKey(nameMapper, sourceField, key);
    }
    return new EqualsCondition(compositeKey.addKey(nameMapper, mergeField, ((EqualsCondition) condition).getKey()));
  } else if(condition instanceof RangeCondition) {
    RangeCondition rangeCondition = (RangeCondition) condition;
    Key startKey = null, endKey = null;
    if(rangeCondition.getStart() != null) {
      startKey = new CompositeKey()
          .addKey(nameMapper, sourceField, key)
          .addKey(nameMapper, mergeField, rangeCondition.getStart());
    }
    if(rangeCondition.getEnd() != null) {
      endKey = new CompositeKey()
          .addKey(nameMapper, sourceField, key)
          .addKey(nameMapper, mergeField, rangeCondition.getEnd());
    }
    return new RangeCondition(startKey, rangeCondition.isStartIncluded(), endKey, rangeCondition.isEndIncluded());
  }
  return null;
}
origin: oberasoftware/jasdb

private static RangeCondition mergeRangeConditions(List<RangeCondition> rangeConditions) {
  Key lowestKey = null;
  boolean startInclusive = false;
  boolean endInclusive = false;
  Key highestKey = null;
  for(SearchCondition condition : rangeConditions) {
    RangeCondition rangeCondition = (RangeCondition) condition;
    Key rangeStartKey = rangeCondition.getStart();
    Key rangeEndKey = rangeCondition.getEnd();
    if(rangeStartKey != null && (lowestKey == null || rangeStartKey.compareTo(lowestKey) < 0)) {
      lowestKey = rangeStartKey;
      startInclusive = rangeCondition.isStartIncluded();
    }
    if(rangeEndKey != null && (highestKey == null || rangeEndKey.compareTo(highestKey) > 0)) {
      highestKey = rangeEndKey;
      endInclusive = rangeCondition.isEndIncluded();
    }
  }
  return new RangeCondition(lowestKey, startInclusive, highestKey, endInclusive);
}
origin: oberasoftware/jasdb

private static SearchCondition createCondition(QueryField queryField) {
  Key searchKey = valueToKey(queryField.getSearchKey());
  switch(queryField.getOperator()) {
    case LARGER_THAN:
      return new RangeCondition(searchKey, false, null, false);
    case LARGER_THAN_OR_EQUALS:
      return new RangeCondition(searchKey, true, null, false);
    case SMALLER_THAN:
      return new RangeCondition(null,  false, searchKey, false);
    case SMALLER_THAN_OR_EQUALS:
      return new RangeCondition(null,  false, searchKey, true);
    case NOT_EQUALS:
      return new NotEqualsCondition(searchKey);
    case EQUALS:
    default:
      return new EqualsCondition(searchKey);
  }
}
origin: oberasoftware/jasdb

private RangeCondition validateRangeCondition(SearchCondition condition) throws JasDBStorageException {
  if(condition instanceof RangeCondition) {
    KeyFactory factory = keyInfo.getKeyFactory();
    RangeCondition rangeCondition = (RangeCondition) condition;
    rangeCondition.setStart(validateKey(factory, rangeCondition.getStart()));
    rangeCondition.setEnd(validateKey(factory, rangeCondition.getEnd()));
    return rangeCondition;
  } else {
    throw new JasDBStorageException("Invalid Range condition input: " + condition);
  }
}
origin: oberasoftware/jasdb

protected static EqualsCondition validateCondition(KeyInfo keyInfo, SearchCondition condition) throws JasDBStorageException {
  if(condition instanceof EqualsCondition) {
    EqualsCondition equalsCondition = (EqualsCondition) condition;
    KeyFactory keyFactory = keyInfo.getKeyFactory();
    if(!keyFactory.supportsKey(equalsCondition.getKey())) {
      Key supportedKey = keyFactory.convertKey(equalsCondition.getKey());
      return new EqualsCondition(supportedKey);
    } else {
      return equalsCondition;
    }
  } else {
    throw new JasDBStorageException("Invalid Equals condition input: " + condition);
  }
}
origin: oberasoftware/jasdb

@Override
public SearchCondition mergeCondition(KeyNameMapper nameMapper, String sourceField, String mergeField, SearchCondition condition) {
  if(condition instanceof NotEqualsCondition) {
    CompositeKey compositeKey;
    Key key = getKey();
    if(key instanceof CompositeKey) {
      compositeKey = (CompositeKey) key;
    } else {
      compositeKey = new CompositeKey();
      compositeKey.addKey(nameMapper, sourceField, key);
    }
    return new NotEqualsCondition(compositeKey.addKey(nameMapper, mergeField, ((EqualsCondition) condition).getKey()));
  }
  return null;
}
origin: oberasoftware/jasdb

@Override
public List<IndexField> getIndexValueFields() {
  List<IndexField> valueFields = new ArrayList<>();
  for(KeyFactory vKeyFactory : multiValueKeyLoader.getKeyFactories()) {
    valueFields.add(new SimpleIndexField(vKeyFactory.getFieldName(), vKeyFactory.getKeyType()));
  }
  return valueFields;
}
origin: oberasoftware/jasdb

  @Override
  public IndexSearchResultIteratorCollection search(SearchCondition condition, SearchLimit limit) throws JasDBStorageException {
    IndexIterator indexIterator = new FullIndexIterator(rootBlock, lockManager, blockPersister);

    EqualsCondition equalsCondition = EqualsSearchOperation.validateCondition(keyInfo, condition);
    Key undesiredKey = equalsCondition.getKey();

    List<Key> results = new LinkedList<>();
    for(Key key : indexIterator) {
      if(key.compare(undesiredKey, CompareMethod.EQUALS).getCompare() != 0) {
        results.add(key);
      }

      if(limit.isMaxReached(results.size())) {
        break;
      }
    }

    return new IndexSearchResultIteratorImpl(results, keyInfo.getKeyNameMapper());
  }
}
origin: oberasoftware/jasdb

@Override
public RecordResult readRecord(UUIDKey documentId) throws JasDBStorageException {
  IndexSearchResultIterator resultIterator = index.searchIndex(new EqualsCondition(documentId), Index.NO_SEARCH_LIMIT);
  if(!resultIterator.isEmpty()) {
    Key key = resultIterator.next();
    DataKey dataKey = (DataKey) key.getKey(keyInfo.getKeyNameMapper(), "data");
    return new BtreeRecordResult(dataKey);
  } else {
    return new BtreeRecordResult();
  }
}
origin: oberasoftware/jasdb

private static void generateEqualsCondition(StringBuilder builder, String field, EqualsCondition equalsCondition) {
  Key key = equalsCondition.getKey();
  builder.append(field).append("=");
  handleValueAppend(builder, key);
}
origin: oberasoftware/jasdb

@Override
public boolean keyQualifies(Key key) {
  return getKey().compareTo(key) != 0;
}
origin: oberasoftware/jasdb

@Override
public IndexSearchResultIteratorCollection mergeIterators(IndexSearchResultIteratorCollection mergeInto, IndexSearchResultIteratorCollection... results) {
  List<Key> mergedKeys = new ArrayList<>(mergeInto.getKeys());
  for(IndexSearchResultIteratorCollection collection : results) {
    mergeInto(mergedKeys, collection);
  }
  return new IndexSearchResultIteratorImpl(mergedKeys, mergeInto.getKeyNameMapper());
}

origin: oberasoftware/jasdb

private static void generateRangeCondition(StringBuilder builder, String field, RangeCondition rangeCondition) {
  Key startKey = rangeCondition.getStart();
  Key endKey = rangeCondition.getEnd();
  if(startKey != null) {
    builder.append(field).append(rangeCondition.isStartIncluded() ? ">=" : ">");
    handleValueAppend(builder, startKey);
  }
  if(startKey != null && endKey != null) {
    builder.append(",");
  }
  if(endKey != null) {
    builder.append(field).append(rangeCondition.isEndIncluded() ? "<=" : "<");
    handleValueAppend(builder, endKey);
  }
}
origin: oberasoftware/jasdb

@Override
public Index createIndex(String bagName, IndexField indexField, boolean unique, IndexField... valueFields) throws JasDBStorageException {
  KeyInfo keyInfo;
  if(unique) {
    keyInfo = new KeyInfoImpl(indexField, guaranteeIdKey(valueFields));
  } else {
    keyInfo = new KeyInfoImpl(Lists.newArrayList(indexField, new SimpleIndexField(SimpleEntity.DOCUMENT_ID, new UUIDKeyType())), Lists.newArrayList(valueFields));
  }
  return createInStore(bagName, keyInfo);
}
origin: oberasoftware/jasdb

@Override
public IndexSearchResultIteratorCollection search(SearchCondition condition, SearchLimit limit) throws JasDBStorageException {
  EqualsCondition equalsCondition = validateCondition(keyInfo, condition);
  Key desiredKey = equalsCondition.getKey();
  lockManager.startLockChain();
  lockManager.acquireLock(LockIntentType.READ, rootBlock);
  try {
    LeaveBlock leaveBlock = rootBlock.findLeaveBlock(LockIntentType.READ, equalsCondition.getKey());
    return doLeaveSearch(leaveBlock, desiredKey);
  } finally {
    lockManager.releaseLockChain();
  }
}
origin: oberasoftware/jasdb

private static void generateNotEqualsCondition(StringBuilder builder, String field, NotEqualsCondition notEqualsCondition) {
  Key key = notEqualsCondition.getKey();
  builder.append(field).append("!=");
  handleValueAppend(builder, key);
}
origin: oberasoftware/jasdb

private IndexSearchResultIteratorCollection doLeaveSearch(LeaveBlock leaveBlock, Key desiredKey) {
  List<Key> results = new ArrayList<>(1);
  if(leaveBlock.contains(desiredKey)) {
    results.add(leaveBlock.getKey(desiredKey));
  }
  return new IndexSearchResultIteratorImpl(results, keyInfo.getKeyNameMapper().clone());
}
com.oberasoftware.jasdb.core.index.query

Most used classes

  • EqualsCondition
  • SimpleIndexField
    This represents a field that needs to be indexed.
  • RangeCondition
  • IndexSearchResultIteratorImpl
  • NotEqualsCondition
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