com.redhat.lightblue.mindex.GetIndexLookupSpec Maven / Gradle / Ivy
/*
Copyright 2013 Red Hat, Inc. and/or its affiliates.
This file is part of lightblue.
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 3 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, see .
*/
package com.redhat.lightblue.mindex;
import java.util.List;
import java.util.ArrayList;
import java.util.stream.Collectors;
import com.redhat.lightblue.assoc.QueryFieldInfo;
import com.redhat.lightblue.metadata.ArrayField;
import com.redhat.lightblue.query.*;
import com.redhat.lightblue.util.Path;
import com.redhat.lightblue.util.Error;
/**
* Given a query and key spec, builds a lookup spec
*
* This class follows the same pattern as GetIndexKeySpec
*/
public class GetIndexLookupSpec extends IndexQueryProcessorBase {
private static final String REGEX_CHARS="$[]*.\\^-&|{}()?+:<>!=";
public GetIndexLookupSpec(List l) {
super(l);
}
@Override
protected LookupSpec processValueComparisonExpression(ValueComparisonExpression q) {
switch(q.getOp()) {
case _eq:
return new ValueLookupSpec(simpleKeySpec(findFieldInfo(q.getField(),q)),q.getRvalue().getValue());
case _lte:
case _lt:
return new RangeLookupSpec(simpleKeySpec(findFieldInfo(q.getField(),q)),null,q.getRvalue().getValue());
case _gte:
case _gt:
return new RangeLookupSpec(simpleKeySpec(findFieldInfo(q.getField(),q)),q.getRvalue().getValue(),null);
}
return null;
}
static String getPrefix(String pattern) {
StringBuilder bld=new StringBuilder();
int n=pattern.length();
for(int i=0;i list,Path context) {
// Here, we're sure that all queries in the list refer to the same field, and there is only one
// SimpleKeySpec for the whole list
// Thus, we build a multiValuelookupSpec
List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy