Skip to content

Commit

Permalink
Remove unused class OnlySingleValueAllowed
Browse files Browse the repository at this point in the history
  • Loading branch information
felixbarny committed Aug 29, 2024
1 parent 1365d31 commit 10113c7
Showing 1 changed file with 0 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import org.elasticsearch.index.IndexSettings;

import java.net.InetAddress;
import java.util.HashSet;
import java.util.Set;

/**
* Collects dimensions from documents.
Expand Down Expand Up @@ -48,63 +46,6 @@ default DocumentDimensions addString(String fieldName, String value) {

DocumentDimensions validate(IndexSettings settings);

/**
* Makes sure that each dimension only appears on time.
*/
class OnlySingleValueAllowed implements DocumentDimensions {
private final Set<String> names = new HashSet<>();

@Override
public DocumentDimensions addString(String fieldName, BytesRef value) {
add(fieldName);
return this;
}

// Override to skip the UTF-8 conversion that happens in the default implementation
@Override
public DocumentDimensions addString(String fieldName, String value) {
add(fieldName);
return this;
}

@Override
public DocumentDimensions addIp(String fieldName, InetAddress value) {
add(fieldName);
return this;
}

@Override
public DocumentDimensions addLong(String fieldName, long value) {
add(fieldName);
return this;
}

@Override
public DocumentDimensions addUnsignedLong(String fieldName, long value) {
add(fieldName);
return this;
}

@Override
public DocumentDimensions addBoolean(String fieldName, boolean value) {
add(fieldName);
return this;
}

@Override
public DocumentDimensions validate(final IndexSettings settings) {
// DO NOTHING
return this;
}

private void add(String fieldName) {
boolean isNew = names.add(fieldName);
if (false == isNew) {
throw new IllegalArgumentException("Dimension field [" + fieldName + "] cannot be a multi-valued field.");
}
}
};

/**
* Noop implementation that doesn't perform validations on dimension fields
*/
Expand Down

0 comments on commit 10113c7

Please sign in to comment.