-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
`_tsid` is built by getting a sorted list of encoded dimensions. This creates a `TimeSeriesIdBuilder` that abstracts that behind sensibly named methods.
- Loading branch information
Showing
15 changed files
with
223 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
server/src/main/java/org/elasticsearch/index/mapper/DocumentDimensions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.index.mapper; | ||
|
||
import java.net.InetAddress; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
/** | ||
* Collects dimensions from documents. | ||
*/ | ||
public interface DocumentDimensions { | ||
void addString(String fieldName, String value); | ||
|
||
void addIp(String fieldName, InetAddress value); | ||
|
||
void addLong(String fieldName, long value); | ||
|
||
void addUnsignedLong(String fieldName, long value); | ||
|
||
/** | ||
* Makes sure that each dimension only appears on time. | ||
*/ | ||
class OnlySingleValueAllowed implements DocumentDimensions { | ||
private final Set<String> names = new HashSet<>(); | ||
|
||
@Override | ||
public void addString(String fieldName, String value) { | ||
add(fieldName); | ||
} | ||
|
||
@Override | ||
public void addIp(String fieldName, InetAddress value) { | ||
add(fieldName); | ||
} | ||
|
||
@Override | ||
public void addLong(String fieldName, long value) { | ||
add(fieldName); | ||
} | ||
|
||
@Override | ||
public void addUnsignedLong(String fieldName, long value) { | ||
add(fieldName); | ||
} | ||
|
||
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."); | ||
} | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.