<commit_before>// Copyright 2017 Aerospike, Inc.
//
// 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 aerospike_test

import (
	"fmt"
	"time"

	as "github.com/aerospike/aerospike-client-go"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

// ALL tests are isolated by SetName and Key, which are 50 random characters
var _ = Describe("predexp operations", func() {
	initTestVars()

	const keyCount = 1000

	var ns = *namespace
	var set = "predexp_tests" // The name of the set should be consistent because of predexp_modulo tests, since set name is a part of the digest
	var wpolicy = as.NewWritePolicy(0, 0)

	starbucks := [][2]float64{
		{-122.1708441, 37.4241193},
		{-122.1492040, 37.4273569},
		{-122.1441078, 37.4268202},
		{-122.1251714, 37.4130590},
		{-122.0964289, 37.4218102},
		{-122.0776641, 37.4158199},
		{-122.0943475, 37.4114654},
		{-122.1122861, 37.4028493},
		{-122.0947230, 37.3909250},
		{-122.0831037, 37.3876090},
		{-122.0707119, 37.3787855},
		{-122.0303178, 37.3882739},
		{-122.0464861, 37.3786236},
		{-122.0582128, 37.3726980},
		{-122.0365083, 37.3676930},
	}

	var gaptime int64

	BeforeEach(func() {
		wpolicy = as.NewWritePolicy(0, 24*60*60)

		for ii := 0; ii < keyCount; ii++ {

			// On iteration 333 we pause for a few mSec and note the
			// time.  Later we can check last_update time for either
			// side of this gap ...
			//
			// Also, we update the WritePolicy to never expire so
			// records w/ 0 TTL can be counted later.
			//
			if ii == 333 {
				<-time.After(5 * time.Millisecond)
				gaptime = time.Now().UnixNano()
				<-time.After(5 * time.Millisecond)

				wpolicy = as.NewWritePolicy(0, as.TTLDontExpire)
			}

			key, err := as.NewKey(ns, set, ii)
			Expect(err).ToNot(HaveOccurred())

			lng := -122.0 + (0.1 * float64(ii))
			lat := 37.5 + (0.1 * float64(ii))
			pointstr := fmt.Sprintf(
				"{ \"type\": \"Point\", \"coordinates\": [%f, %f] }",
				lng, lat)

			var regionstr string
			if ii < len(starbucks) {<commit_msg>Allow more tollerance for predexp tests to pass in slow environments<commit_after>// Copyright 2017 Aerospike, Inc.
//
// 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 aerospike_test

import (
	"fmt"
	"time"

	as "github.com/aerospike/aerospike-client-go"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

// ALL tests are isolated by SetName and Key, which are 50 random characters
var _ = Describe("predexp operations", func() {
	initTestVars()

	const keyCount = 1000

	var ns = *namespace
	var set = "predexp_tests" // The name of the set should be consistent because of predexp_modulo tests, since set name is a part of the digest
	var wpolicy = as.NewWritePolicy(0, 0)

	starbucks := [][2]float64{
		{-122.1708441, 37.4241193},
		{-122.1492040, 37.4273569},
		{-122.1441078, 37.4268202},
		{-122.1251714, 37.4130590},
		{-122.0964289, 37.4218102},
		{-122.0776641, 37.4158199},
		{-122.0943475, 37.4114654},
		{-122.1122861, 37.4028493},
		{-122.0947230, 37.3909250},
		{-122.0831037, 37.3876090},
		{-122.0707119, 37.3787855},
		{-122.0303178, 37.3882739},
		{-122.0464861, 37.3786236},
		{-122.0582128, 37.3726980},
		{-122.0365083, 37.3676930},
	}

	var gaptime int64

	BeforeEach(func() {
		wpolicy = as.NewWritePolicy(0, 24*60*60)

		for ii := 0; ii < keyCount; ii++ {

			// On iteration 333 we pause for a few mSec and note the
			// time.  Later we can check last_update time for either
			// side of this gap ...
			//
			// Also, we update the WritePolicy to never expire so
			// records w/ 0 TTL can be counted later.
			//
			if ii == 333 {
				<-time.After(500 * time.Millisecond)
				gaptime = time.Now().UnixNano()
				<-time.After(500 * time.Millisecond)

				wpolicy = as.NewWritePolicy(0, as.TTLDontExpire)
			}

			key, err := as.NewKey(ns, set, ii)
			Expect(err).ToNot(HaveOccurred())

			lng := -122.0 + (0.1 * float64(ii))
			lat := 37.5 + (0.1 * float64(ii))
			pointstr := fmt.Sprintf(
				"{ \"type\": \"Point\", \"coordinates\": [%f, %f] }",
				lng, lat)

			var regionstr string
			if ii < len(starbucks) {
{'fraction_non_alphanumeric': 0.14288533649102034, 'fraction_numerical': 0.134596408131044, 'mean_word_length': 3.0903954802259888, 'pattern_counts': {'":': 4, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3658919', 'n_tokens_mistral': 2405, 'n_tokens_neox': 1789, 'n_words': 554}