@Test public void testPropertyValueWithSpecialCharacters() throws Exception { assertFalse(SegmentColumnarIndexCreator.isValidPropertyValue(" a")); assertFalse(SegmentColumnarIndexCreator.isValidPropertyValue("a\t")); assertFalse(SegmentColumnarIndexCreator.isValidPropertyValue("\na")); assertTrue(SegmentColumnarIndexCreator.isValidPropertyValue("a\t b")); testPropertyValueWithSpecialCharacters("a\t b"); assertTrue(SegmentColumnarIndexCreator.isValidPropertyValue("a \nb")); testPropertyValueWithSpecialCharacters("a \nb"); assertFalse(SegmentColumnarIndexCreator.isValidPropertyValue("a,b,c")); assertFalse(SegmentColumnarIndexCreator.isValidPropertyValue(",a b")); assertTrue(SegmentColumnarIndexCreator.isValidPropertyValue("")); testPropertyValueWithSpecialCharacters(""); assertTrue(SegmentColumnarIndexCreator.isValidPropertyValue("$${testKey}")); testPropertyValueWithSpecialCharacters("$${testKey}"); assertTrue(SegmentColumnarIndexCreator.isValidPropertyValue("$${")); testPropertyValueWithSpecialCharacters("$${"); for (int i = 0; i < NUM_ROUNDS; i++) { testPropertyValueWithSpecialCharacters(RandomStringUtils.randomAscii(5)); testPropertyValueWithSpecialCharacters(RandomStringUtils.random(5)); } }
@VisibleForTesting static boolean isValidPropertyValue(String value) { int length = value.length(); if (length == 0) { return true; } if (length > METADATA_PROPERTY_LENGTH_LIMIT) { return false; } if (Character.isWhitespace(value.charAt(0)) || Character.isWhitespace(value.charAt(length - 1))) { return false; } return value.indexOf(',') == -1; }
SegmentColumnarIndexCreator implements SegmentCreator { @VisibleForTesting static boolean isValidPropertyValue(String value) { int length = value.length(); if (length == 0) { return true; } if (length > METADATA_PROPERTY_LENGTH_LIMIT) { return false; } if (Character.isWhitespace(value.charAt(0)) || Character.isWhitespace(value.charAt(length - 1))) { return false; } return value.indexOf(',') == -1; } }
SegmentColumnarIndexCreator implements SegmentCreator { @VisibleForTesting static boolean isValidPropertyValue(String value) { int length = value.length(); if (length == 0) { return true; } if (length > METADATA_PROPERTY_LENGTH_LIMIT) { return false; } if (Character.isWhitespace(value.charAt(0)) || Character.isWhitespace(value.charAt(length - 1))) { return false; } return value.indexOf(',') == -1; }  }
SegmentColumnarIndexCreator implements SegmentCreator { @VisibleForTesting static boolean isValidPropertyValue(String value) { int length = value.length(); if (length == 0) { return true; } if (length > METADATA_PROPERTY_LENGTH_LIMIT) { return false; } if (Character.isWhitespace(value.charAt(0)) || Character.isWhitespace(value.charAt(length - 1))) { return false; } return value.indexOf(',') == -1; }  @Override void init(SegmentGeneratorConfig segmentCreationSpec, SegmentIndexCreationInfo segmentIndexCreationInfo,
      Map<String, ColumnIndexCreationInfo> indexCreationInfoMap, Schema schema, File outDir); static boolean shouldDeriveNumDocsPerChunk(String columnName,
      Map<String, Map<String, String>> columnProperties); static int rawIndexWriterVersion(String columnName, Map<String, Map<String, String>> columnProperties); @Override void indexRow(GenericRow row); @Override void setSegmentName(String segmentName); @Override void seal(); static void addColumnMetadataInfo(PropertiesConfiguration properties, String column,
      ColumnIndexCreationInfo columnIndexCreationInfo, int totalDocs, FieldSpec fieldSpec, boolean hasDictionary,
      int dictionaryElementSize, boolean hasInvertedIndex, TextIndexType textIndexType); static void addColumnMinMaxValueInfo(PropertiesConfiguration properties, String column, String minValue,
      String maxValue); static void removeColumnMetadataInfo(PropertiesConfiguration properties, String column); static ForwardIndexCreator getRawIndexCreatorForColumn(File file,
      ChunkCompressorFactory.CompressionType compressionType, String column, DataType dataType, int totalDocs,
      int lengthOfLongestEntry, boolean deriveNumDocsPerChunk, int writerVersion); @Override void close(); }
SegmentColumnarIndexCreator implements SegmentCreator { @VisibleForTesting static boolean isValidPropertyValue(String value) { int length = value.length(); if (length == 0) { return true; } if (length > METADATA_PROPERTY_LENGTH_LIMIT) { return false; } if (Character.isWhitespace(value.charAt(0)) || Character.isWhitespace(value.charAt(length - 1))) { return false; } return value.indexOf(',') == -1; }  @Override void init(SegmentGeneratorConfig segmentCreationSpec, SegmentIndexCreationInfo segmentIndexCreationInfo,
      Map<String, ColumnIndexCreationInfo> indexCreationInfoMap, Schema schema, File outDir); static boolean shouldDeriveNumDocsPerChunk(String columnName,
      Map<String, Map<String, String>> columnProperties); static int rawIndexWriterVersion(String columnName, Map<String, Map<String, String>> columnProperties); @Override void indexRow(GenericRow row); @Override void setSegmentName(String segmentName); @Override void seal(); static void addColumnMetadataInfo(PropertiesConfiguration properties, String column,
      ColumnIndexCreationInfo columnIndexCreationInfo, int totalDocs, FieldSpec fieldSpec, boolean hasDictionary,
      int dictionaryElementSize, boolean hasInvertedIndex, TextIndexType textIndexType); static void addColumnMinMaxValueInfo(PropertiesConfiguration properties, String column, String minValue,
      String maxValue); static void removeColumnMetadataInfo(PropertiesConfiguration properties, String column); static ForwardIndexCreator getRawIndexCreatorForColumn(File file,
      ChunkCompressorFactory.CompressionType compressionType, String column, DataType dataType, int totalDocs,
      int lengthOfLongestEntry, boolean deriveNumDocsPerChunk, int writerVersion); @Override void close();  }