private HBaseStatus(File file, String version) { Preconditions.checkNotNull(file); Preconditions.checkNotNull(version); this.file = file; this.version = version; }
private Shape convertObjectToShapeIfPossible(Object o) throws IOException { if(o instanceof Shape) return (Shape) o; String geoShapeStringValue = null; if(o instanceof HashMap) { HashMap map = (HashMap) o; Preconditions.checkArgument(map.containsKey("coordinates") && map.containsKey("type")); geoShapeStringValue = (new JSONObject(map)).toString(); } else if (o instanceof String){ geoShapeStringValue = (String) o; } Preconditions.checkNotNull(geoShapeStringValue); XContentParser parser = JsonXContent.jsonXContent.createParser(geoShapeStringValue); parser.nextToken(); return ShapeBuilder.parse(parser).build(); }
final int count = nodeIntegerValue(termMap.get("count")); final Object actualTerm = termMap.get("term"); checkNotNull(actualTerm); if (actualTerm instanceof Double) { if (doubleEntries == null) { doubleEntries = new ArrayList<InternalDoubleTermsFacet.DoubleEntry>(terms.size());} checkState(stringEntries == null && longEntries == null); return new InternalDoubleTermsFacet(facetName, comparatorType, doubleEntries.size(), doubleEntries, missing, total); } else if (stringEntries != null) { checkState(longEntries == null); return new InternalStringTermsFacet(facetName, comparatorType, stringEntries.size(), stringEntries, missing, total); } else if (longEntries != null) { return new InternalLongTermsFacet(facetName, comparatorType, longEntries.size(), longEntries, missing, total); } else { checkState(terms.isEmpty());
private static <K, V> Map.Entry<K, V> first(final Map<K, V> map) { Preconditions.checkArgument(!map.isEmpty()); return map.entrySet().iterator().next(); }
final double mean = nodeDoubleValue(entryMap.get("mean"), Double.NaN); if (Double.isNaN(min) && Double.isNaN(max) && Double.isNaN(total) && Double.isNaN(mean) && totalCount == 0) { checkState(fullEntries == null); if (countEntries == null) { countEntries = new InternalCountHistogramFacet.CountEntry[entries.size()]; checkState(countEntries == null); if (fullEntries == null) { fullEntries = new InternalFullHistogramFacet.FullEntry[entries.size()]; return new InternalCountHistogramFacet(facetName, comparatorType, countEntries); } else { checkState(fullEntries != null); return new InternalFullHistogramFacet(facetName, comparatorType, Arrays.asList(fullEntries));
final int count = nodeIntegerValue(termMap.get("count")); final Object actualTerm = termMap.get("term"); checkNotNull(actualTerm); if (actualTerm instanceof Double) { if (doubleEntries == null) { doubleEntries = new ArrayList<InternalDoubleTermsFacet.DoubleEntry>(terms.size());} checkState(stringEntries == null && longEntries == null); return new InternalDoubleTermsFacet(facetName, comparatorType, doubleEntries.size(), doubleEntries, missing, total); } else if (stringEntries != null) { checkState(longEntries == null); return new InternalStringTermsFacet(facetName, comparatorType, stringEntries.size(), stringEntries, missing, total); } else if (longEntries != null) { return new InternalLongTermsFacet(facetName, comparatorType, longEntries.size(), longEntries, missing, total); } else { checkState(terms.isEmpty());
private static <K, V> Map.Entry<K, V> first(final Map<K, V> map) { Preconditions.checkArgument(!map.isEmpty()); return map.entrySet().iterator().next(); }
final double mean = nodeDoubleValue(entryMap.get("mean"), Double.NaN); if (Double.isNaN(min) && Double.isNaN(max) && Double.isNaN(total) && Double.isNaN(mean) && totalCount == 0) { checkState(fullEntries == null); if (countEntries == null) { countEntries = new InternalCountDateHistogramFacet.CountEntry[entries.size()]; checkState(countEntries == null); if (fullEntries == null) { fullEntries = new InternalFullDateHistogramFacet.FullEntry[entries.size()]; return new InternalCountDateHistogramFacet(facetName, comparatorType, countEntries); } else { checkState(fullEntries != null); return new InternalFullDateHistogramFacet(facetName, comparatorType, Arrays.asList(fullEntries));
Preconditions.checkNotNull(riverName, "No riverName specified"); Preconditions.checkNotNull(riverIndexName, "No riverIndexName specified"); Preconditions.checkNotNull(settings, "No settings specified");
public GeoBoundingBox(GeoPoint topLeft, GeoPoint bottomRight) { Preconditions.checkArgument(topLeft.getLat() >= bottomRight.getLat()); Preconditions.checkArgument(topLeft.getLon() <= bottomRight.getLon()); this.topLeft = topLeft; this.bottomRight = bottomRight; }
final double mean = nodeDoubleValue(entryMap.get("mean"), Double.NaN); if (Double.isNaN(min) && Double.isNaN(max) && Double.isNaN(total) && Double.isNaN(mean) && totalCount == 0) { checkState(fullEntries == null); if (countEntries == null) { countEntries = new InternalCountDateHistogramFacet.CountEntry[entries.size()]; checkState(countEntries == null); if (fullEntries == null) { fullEntries = new InternalFullDateHistogramFacet.FullEntry[entries.size()]; return new InternalCountDateHistogramFacet(facetName, comparatorType, countEntries); } else { checkState(fullEntries != null); return new InternalFullDateHistogramFacet(facetName, comparatorType, Arrays.asList(fullEntries));
public DefaultClientProvider(Client client, boolean closeClientOnTerminate) { Preconditions.checkNotNull(client, "No Client specified"); this.closeOnTerminate = closeClientOnTerminate; this.client = client; }
final double mean = nodeDoubleValue(entryMap.get("mean"), Double.NaN); if (Double.isNaN(min) && Double.isNaN(max) && Double.isNaN(total) && Double.isNaN(mean) && totalCount == 0) { checkState(fullEntries == null); if (countEntries == null) { countEntries = new InternalCountHistogramFacet.CountEntry[entries.size()]; checkState(countEntries == null); if (fullEntries == null) { fullEntries = new InternalFullHistogramFacet.FullEntry[entries.size()]; return new InternalCountHistogramFacet(facetName, comparatorType, countEntries); } else { checkState(fullEntries != null); return new InternalFullHistogramFacet(facetName, comparatorType, Arrays.asList(fullEntries));
public ClassPathJSONProvider(Class klass, String path) { Preconditions.checkNotNull(klass, "No Class specified"); this.klass = klass; this.path = path; }
private static ShardSearchFailure[] getShardSearchFailures(final Map<String, Object> shards, final int failedShards) { final ShardSearchFailure[] shardSearchFailures = new ShardSearchFailure[failedShards]; if (failedShards == 0) { Preconditions.checkState(!shards.containsKey("failures")); return shardSearchFailures; } Object[] failures = nodeListValue(shards.get("failures"), Object.class).toArray(); for (int i = 0; i < failedShards; i++) { Map<String, Object> failure = nodeMapValue(failures[i], String.class, Object.class); SearchShardTarget shard = null; if (failure.containsKey("index") && failure.containsKey("shard")) { String index = nodeStringValue(failure.get("index"), null); Integer shardId = nodeIntegerValue(failure.get("shard")); shard = new SearchShardTarget(null, index, shardId); } shardSearchFailures[i] = new ShardSearchFailure( nodeStringValue(failure.get("reason"), null), shard, findRestStatus(nodeIntegerValue(failure.get("status"))) ); } return shardSearchFailures; }
public ClassPathJSONProvider(ClassLoader classLoader, String path) { Preconditions.checkNotNull(classLoader, "No ClassLoader specified"); this.classLoader = classLoader; this.path = path; }
private static ShardSearchFailure[] getShardSearchFailures(final Map<String, Object> shards, final int failedShards) { final ShardSearchFailure[] shardSearchFailures = new ShardSearchFailure[failedShards]; if (failedShards == 0) { Preconditions.checkState(!shards.containsKey("failures")); return shardSearchFailures; } Object[] failures = nodeListValue(shards.get("failures"), Object.class).toArray(); for (int i = 0; i < failedShards; i++) { Map<String, Object> failure = nodeMapValue(failures[i], String.class, Object.class); SearchShardTarget shard = null; if (failure.containsKey("index") && failure.containsKey("shard")) { String index = nodeStringValue(failure.get("index"), null); Integer shardId = nodeIntegerValue(failure.get("shard")); shard = new SearchShardTarget(null, index, shardId); } shardSearchFailures[i] = new ShardSearchFailure( nodeStringValue(failure.get("reason"), null), shard, findRestStatus(nodeIntegerValue(failure.get("status"))) ); } return shardSearchFailures; }
public static <T> T notNull(T t) { checkNotNull(t); return t; } }
checkState(stringEntries == null && longEntries == null); return new InternalTermsStatsDoubleFacet(facetName, comparatorType, doubleEntries.size(), doubleEntries, missing); } else if (stringEntries != null) { checkState(longEntries == null); return new InternalTermsStatsStringFacet(facetName, comparatorType, stringEntries.size(), stringEntries, missing); } else if (longEntries != null) { return new InternalTermsStatsLongFacet(facetName, comparatorType, longEntries.size(), longEntries, missing); } else { checkState(terms.isEmpty());
/** * This constructor uses the {@link ClientProvider} to retrieve an instance of {@link Client} and use it to execute requests. * * @param clientProvider the {@link ClientProvider} to use for requests execution */ protected EsSetup(ClientProvider clientProvider) { Preconditions.checkNotNull(clientProvider, "No ClientProvider specified"); provider = clientProvider; }