com.aerospike.client.cdt.CTX Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aerospike-client Show documentation
Show all versions of aerospike-client Show documentation
Aerospike Java client interface to Aerospike database server
/*
* Copyright 2012-2020 Aerospike, Inc.
*
* Portions may be licensed to Aerospike, Inc. under one or more contributor
* license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0.
*
* 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 com.aerospike.client.cdt;
import com.aerospike.client.Value;
/**
* Nested CDT context. Identifies the location of nested list/map to apply the operation.
* for the current level. An array of CTX identifies location of the list/map on multiple
* levels on nesting.
*/
public final class CTX {
/**
* Lookup list by index offset.
*
* If the index is negative, the resolved index starts backwards from end of list.
* If an index is out of bounds, a parameter error will be returned. Examples:
*
* - 0: First item.
* - 4: Fifth item.
* - -1: Last item.
* - -3: Third to last item.
*
*/
public static CTX listIndex(int index) {
return new CTX(0x10, Value.get(index));
}
/**
* Lookup list by base list's index offset. If the list at index offset is not found,
* create it with the given sort order at that index offset. If pad is true and the
* index offset is greater than the bounds of the base list, nil entries will be
* inserted before the newly created list.
*/
public static CTX listIndexCreate(int index, ListOrder order, boolean pad) {
return new CTX(0x10 | order.getFlag(pad), Value.get(index));
}
/**
* Lookup list by rank.
*
* - 0 = smallest value
* - N = Nth smallest value
* - -1 = largest value
*
*/
public static CTX listRank(int rank) {
return new CTX(0x11, Value.get(rank));
}
/**
* Lookup list by value.
*/
public static CTX listValue(Value key) {
return new CTX(0x13, key);
}
/**
* Lookup map by index offset.
*
* If the index is negative, the resolved index starts backwards from end of list.
* If an index is out of bounds, a parameter error will be returned. Examples:
*
* - 0: First item.
* - 4: Fifth item.
* - -1: Last item.
* - -3: Third to last item.
*
*/
public static CTX mapIndex(int index) {
return new CTX(0x20, Value.get(index));
}
/**
* Lookup map by rank.
*
* - 0 = smallest value
* - N = Nth smallest value
* - -1 = largest value
*
*/
public static CTX mapRank(int rank) {
return new CTX(0x21, Value.get(rank));
}
/**
* Lookup map by key.
*/
public static CTX mapKey(Value key) {
return new CTX(0x22, key);
}
/**
* Lookup map by base map's key. If the map at key is not found,
* create it with the given sort order at that key.
*/
public static CTX mapKeyCreate(Value key, MapOrder order) {
return new CTX(0x22 | order.flag, key);
}
/**
* Lookup map by value.
*/
public static CTX mapValue(Value key) {
return new CTX(0x23, key);
}
public final int id;
public final Value value;
private CTX(int id, Value value) {
this.id = id;
this.value = value;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy